The Earth's magnetic field is caused by electric currents generated by the convective motion of molten metal in the outer core (the geodynamo).