Earth’s magnetic field is generated from its outer core, 1,800 miles below the surface, comprised of molten iron and other metals that are constantly churning and acting like a giant generator – known as geodynamo — that generates electric currents that produce the magnetic field.
Source: tatoeba (8983302)