The interior of a magnetar is extremely dense.
Even so, to generate such intense magnetic fields,
this dense material must be turbulent, like
a magnetohydrodynamic dynamo. A
proton-superconductor phase of matter is thought
to support the persistence of generated fields.
See also in The book of science:
Readings in wikipedia: