  Possible origins of the magnetic fields of neutron stars include inheritance
from the main sequence progenitor and dynamo action at some stage of evolution
of progenitor. Inheritance is not sufficient to explain the fields of
magnetars. Energetic considerations point to differential rotation in the final
stages of core collapse process as the most likely source of field generation,
at least for magnetars. A runaway phase of exponential growth is needed to
achieve sufficient field amplification during relevant phase of core collapse;
it can probably be provided by a some form of magnetorotational instability.
Once formed in core collapse, the field is in danger of decaying again by
magnetic instabilities. The evolution of a magnetic field in a newly formed
neutron star is discussed, with emphasis on the existence of stable equilibrium
configurations as end products of this evolution, and the role of magnetic
helicity in their existence.
