The geodynamo is the process that generates Earth's magnetic field through moving, electrically conducting fluid in its outer core.
Earth's outer core is primarily liquid iron alloy. Heat escaping from the core and the solidification of the inner core drive convection, while Earth's rotation organizes some of the motion through the Coriolis effect. Moving conductive fluid creates electric currents, and those currents sustain a large-scale magnetic field.
The field is not produced by a permanent magnet at Earth's center, because the core is far too hot for ordinary ferromagnetism to persist there. Earth's magnetic poles also move over time, and geological evidence shows that the field has reversed polarity repeatedly in the past.