Abstract Low-field magnetars have dipolar magnetic fields of 1012–1013 G, 10–100 times weaker than the values of magnetic-field strength B ≈ 1014–1015 G used to define classical magnetars, yet they produce similar X-ray bursts and outbursts. Using direct numerical simulations of magnetothermal evolution starting from a dynamo-generated magnetic field, we show that the low-field magnetars can be produced as a result of a Tayler–Spruit dynamo inside a proto-neutron star.