Neutron stars possess some of the strongest magnetic fields known in the universe. The surface magnetic fields of radio pulsars are estimated to be in the range 10 8 to 10 13 Gauss, with 10 12 Gauss being the typical value. Magnetars, a class of neutron stars with even stronger magnetic fields, ∼ 10 15 Gauss, are believed to be "magnetically powered" stars, deriving most of their radiative luminosity at the cost of their magnetic fields. The origin of the strong magnetic fields of neutron stars, in particular those of magnetars, has essentially been an open question for decades. In this paper we explore the possibility that a magnetar may owe its strong field to a magnetized core which, as indicated by certain equations of state, may form due to phase transitions at high density mediated by strong interaction within a sufficiently massive neutron star. We argue that the field derived from such a core could explain several inferred evolutionary behaviors of magnetars.