Earth's magnetic f
The Earth's magnetic field is thought to be produced by convection currents in the outer liquid of Earth's core. The Dynamo theory proposes that these movements produce electric currents which, in turn, produce the magnetic field.
The presence of this field causes a compass, placed anywhere within it, to rotate so that the "north pole" of the magnet in the compass points roughly north, toward Earth's north magnetic pole. This is the traditional definition of the "north pole" of a magnet, although other equivalent definitions are also possible.
One confusion that arises from this definition is that, if Earth itself is considered as a magnet, the south pole of that magnet would be the one nearer the north magnetic pole, and vice-versa. The north magnetic pole is so-named not because of the polarity of the field there but because of its geographical location. The north and south poles of a permanent magnet are so-called because they are "north-seeking" and "south-seeking", respectively.
The figure to the right is a sketch of Earth's magnetic field represented by field lines. For most locations, the magnetic field has a significant up/down component in addition to the North/South component. (There is also an East/West component; Earth's magnetic poles do not coincide exactly with Earth's geological pole.) The magnetic field can be visualised as a bar magnet buried deep in Earth's interior.
Earth's magnetic field is not constant—the strength of the field and the location of its poles vary. Moreover, the poles periodically reverse their orientation in a process called geomagnetic reversal. The most recent reversal occurred 780,000 years ago.