Asked by: Ahmed Zeb Khattak, Pakistan
It’s the result of the motion of electrons inside atoms. When electrons move through a wire, the resulting current generates a magnetic field. Electrons inside atoms are also moving: they orbit the central nucleus of atoms, and spin on their axes. In most atoms, the resulting magnetic effect is weak. But in some atoms – like those of iron – a kind of subatomic force makes the spins of electrons of neighbouring atoms line up. This allows their individual magnetic fields to combine together, producing a magnetic field that extends beyond the atoms.
Subscribe to BBC Focus magazine for fascinating new Q&As every month and follow @sciencefocusQA on Twitter for your daily dose of fun facts.