Earth’s inner core is a sphere of solid iron, surrounded by liquid iron. Variations in temperature and density create currents in this iron, which in turn produce electrical currents. Lined up by the Earth’s spin, these currents combine to create a magnetic field, used by compass needles worldwide.