Extremely strong magnetic fields of the order of $10^{15},{rm G}$ are required to explain the properties of magnetars, the most magnetic neutron stars. Such a strong magnetic field is expected to play an important role for the dynamics of core-collapse supernovae, and in the presence of rapid rotation may power superluminous supernovae and hypernovae associated to long gamma-ray bursts. The origin of these strong magnetic fields remains, however, obscure and most likely requires an amplification over many orders of magnitude in the protoneutron star. One of the most promising agents is the magnetorotational instability (MRI), which can in principle amplify exponentially fast a weak initial magnetic field to a dynamically relevant strength. We describe our current understanding of the MRI in protoneutron stars and show recent results on its dependence on physical conditions specific to protoneutron stars such as neutrino radiation, strong buoyancy effects and large magnetic Prandtl number.