When an electric current passes through a metal wire, a magnetic field forms around that wire (see diagram at right). Likewise, a wire passing through a magnetic field creates an electric current within the wire. This is the basic principle that allows electric motors and generators to operate.
In the Earth (see image below right), the liquid metal that makes up the outer core passes through a magnetic field, which causes an electric current to flow within the liquid metal. The electric current, in turn, creates its own magnetic field—one that is stronger than the field that created it in the first place. As liquid metal passes through the stronger field, more current flows, which increases the field still further. This self-sustaining loop is known as the geomagnetic dynamo.
Energy is needed to keep the dynamo running. This energy comes from the release of heat from the surface of the solid inner core. Although it may seem counterintuitive, material from the liquid outer core slowly "freezes" onto the inner core, releasing heat as it does so. (High pressures within the Earth cause material to freeze at high temperatures.) This heat drives convection cells within the liquid core, which keeps the liquid metal moving through the magnetic field.
The so-called Coriolis force also plays a role in sustaining the geomagnetic dynamo. Our planet's spinning motion causes the moving liquid metal to spiral, in a way similar to how it affects weather systems on the Earth's surface. These spiraling eddies allow separate magnetic fields to align (more or less) and combine forces. Without the effects caused by the spinning Earth, the magnetic fields generated within the liquid core would cancel one another out and result in no distinct north or south magnetic poles.