The two components needed to form a planetary magnetic field are magnetic material and currents within the conductive material of the core. As the electrically conductive liquid metals of the core pass through a magnetic field, they form what is known as a "geomagnetic dynamo."
Some planets possess the two components needed to generate their own magnetic field. This field is created by the motion of liquid metals found within the planetary interior or core. The energy needed to create and sustain a geomagnetic dynamo is created when heat is released at the surface of a planet's solid inner core.