SUMMARY Phase transitions play an important role for the style of mantle convection. While observations and theory agree that a substantial fraction of subducted slabs and rising plumes can move through the whole mantle at present day conditions, this behaviour may have been different throughout Earth’s history. Higher temperatures, such as in the early Earth, cause different phase transitions to be dominant, and also reduce mantle viscosity, favouring a more layered style of convection induced by phase transitions. A period of layered mantle convection in Earth’s past would have significant implications for the secular evolution of the mantle temperature and the mixing of mantle heterogeneities. The transition from layered to whole mantle convection could lead to a period of mantle avalanches associated with a dramatic increase in magmatic activity. Consequently, it is important to accurately model the influence of phase transitions on mantle convection. However, existing numerical methods generally preclude modelling phase transitions that are only present in a particular range of pressures, temperatures or compositions, and they impose an artificial lower limit on the thickness of phase transitions. To overcome these limitations, we have developed a new numerical method that solves the energy equation for entropy instead of temperature. This technique allows for robust coupling between thermodynamic and geodynamic models and makes it possible to model realistically sharp phase transitions with a wide range of properties and dynamic effects on mantle processes. We demonstrate the utility of our method by applying it in regional and global convection models, investigating the effect of individual phase transitions in the Earth’s mantle with regard to their potential for layering flow. We find that the thickness of the phase transition has a bigger influence on the style of convection than previously thought: with all other parameters being the same, a thin phase transition can induce fully layered convection where a broad phase transition would lead to whole-mantle convection. Our application of the method to convection in the early Earth illustrates that endothermic phase transitions may have induced layering for higher mantle temperatures in the Earth’s past.