On Earth, flowing of liquid metal in the outer core of the planet generates electric currents. The rotation of Earth on its axis causes these electric currents to form a magnetic field which extends around the planet.