The Earth's internal magnetic field varies on timescales of months to billions of years. The field is generated by convection in the liquid outer core, which in turn is influenced by the heat flowing from the core into the base of the overlying mantle. Much of the magnetic field's variation is thought to be stochastic, but over very long timescales, this variability may be related to changes in heat flow associated with mantle convection processes. Over the past 500 Myr, correlations between palaeomagnetic behaviour and surface processes were particularly striking during the middle to late Mesozoic era, beginning about 180 Myr ago. Simulations of the geodynamo suggest that transitions from periods of rapid polarity reversals to periods of prolonged stability — such as occurred between the Middle Jurassic and Middle Cretaceous periods — may have been triggered by a decrease in core–mantle boundary heat flow either globally or in equatorial regions. This decrease in heat flow could have been linked to reduced mantle-plume-head production at the core–mantle boundary, an episode of true polar wander, or a combination of the two.