  Stably stratified layers are present in stellar interiors (radiative zones)
as well as planetary interiors - recent observations and theoretical studies of
the Earth's magnetic field seem to indicate the presence of a thin, stably
stratified layer at the top of the liquid outer core. We present direct
numerical simulations of this region, which is modelled as an axisymmetric
spherical Couette flow for a stably stratified fluid embedded in a dipolar
magnetic field. For strong magnetic fields, a super-rotating shear layer,
rotating nearly 30% faster than the imposed rotation rate difference between
the inner convective dynamo region and the outer boundary, is generated in the
stably stratified region. In the Earth context, and contrary to what was
previously believed, we show that this super-rotation may extend towards the
Earth magnetostrophic regime if the density stratification is sufficiently
large. The corresponding differential rotation triggers magnetohydrodynamic
instabilities and waves in the stratified region, which feature growth rates
comparable to the observed timescale for geomagnetic secular variations and
jerks. In the stellar context, we perform a linear analysis which shows that
similar instabilities are likely to arise, and we argue that it may play a role
in explaining the observed magnetic dichotomy among intermediate-mass stars.
