A magnet has two ends, or poles, referred to as north and south. The north pole of one magnet is attracted to the south pole of another magnet. When an iron nail sticks to a magnet, it is because it has been magnetized, and the south pole of the nail is being attracted by the north pole of the magnet (or vice versa).
When a magnet turns a piece of iron into another magnet, this is called induced magnetism. Iron and other ferrous (ironlike) metals are said to be ferromagnetic because they have properties that enable them to be magnetically induced.
Induced magnetism occurs because a piece of iron is made up of thousands of regions, each of which is like a tiny magnet. Normally, these tiny magnetic regions, called domains, point in many different directions so that their combined magnetism cancels one another out, but when they are magnetically induced, the domains all turn around to point in the same direction.
A domain consists of a cluster of neighboring atoms that align to create a tiny magnet. About 6,000 domains fit onto the head of a pin. Each of these domains is made up of somewhere in the region of a quadrillion atoms (that’s 1,000,000,000,000,000 atoms).
What makes the atoms in a domain magnetic? An atom is made up of a positively charged nucleus surrounded by negatively charged electrons. A magnetic field is produced by an electrical charge in motion, so as these electrons spin around, each of them creates its own tiny magnetic field. In most elements, different electrons produce magnetic fields in different directions and they cancel one another out, but in ferromagnetic elements—such as iron, cobalt, and nickel—the magnetic fields add up, and each atom becomes an atomic magnet. Millions of billions of these atomic magnets line up to become domains, and the domains can be induced to line up to turn an entire piece of ferrous metal into a magnet.
Take the magnet away from the iron nail and you take away the magnetic field that is inducing the domains in the nail to line up. The domains go back to pointing in random directions, and the nail stops being a magnet.
Some metal alloys, such as steel, keep their magnetism after being induced. This is why you can turn a steel sewing needle into a compass needle by stroking it with a magnet.
The reason compass needles point north is that the earth itself is a giant magnet (probably thanks to liquid iron in the earth’s core), but not a very strong one.