Electrons are teeny tiny magnets. They have a north and a south pole, too, and spin around an axis. This spinning results in a very tiny but extremely significant magnetic field. Every electron has one of two possible orientations for its axis.
In most materials, atoms are arranged in such a way that the magnetic orientation of one electron cancels out the orientation of another. Iron and other ferromagnetic substances, though, are different (ferrummeans iron in Latin). Their atomic makeup is such that smaller groups of atoms band together into areas called domains, in which all the electrons have the same magnetic orientation. Below is an applet that shows you how these domains respond to an outside magnetic field.
In the Ferromagnetic Material pictured above, the domains are randomly aligned (the illustration shows how this phenomenon works, not the actual size or shape of domains). Normally invisible Magnetic Field Lines, depicted in red, are seen emanating from the poles of the Bar Magnet. Use the Magnet Position slider to move the magnet closer to the ferromagnetic material so that it interacts with the field lines. As you repeat the process, you’ll notice the domains gradually aligning – with the field of the bar magnet and with each other.
By the time you’re done, the ferromagnetic material has become a permanent magnet itself, a dipole having oppositional north-south poles. A permanent magnet is nothing more than a ferromagnetic object in which all the domains are aligned in the same direction.
There are only four elements in the world that are ferromagnetic at room temperature and can become permanently magnetized: iron, nickel, cobalt and gadolinium. (A fifth element, dysprosium, becomes ferromagnetic at low temperatures.)
Ferromagnets stay magnetized after being subjected to an external magnetic field, sometimes for millions of years. This tendency to retain magnetism is called hysteresis.