We present the first general theory of glacier surging that includes both temperate and polythermal glacier surges, based on coupled mass and enthalpy budgets. Enthalpy (in the form of thermal energy and water) is gained at the glacier bed from geothermal heating plus frictional heating (expenditure of potential energy) as a consequence of ice flow. Enthalpy losses occur by conduction and loss of meltwater from the system. Because enthalpy directly impacts flow speeds, mass and enthalpy budgets must simultaneously balance if a glacier is to maintain a steady flow. If not, glaciers undergo out-of-phase mass and enthalpy cycles, manifest as quiescent and surge phases. We illustrate the theory using a lumped element model, which parameterizes key thermodynamic and hydrological processes, including surface-to-bed drainage and distributed and channelized drainage systems. Model output exhibits many of the observed characteristics of polythermal and temperate glacier surges, including the association of surging behaviour with particular combinations of climate (precipitation, temperature), geometry (length, slope) and bed properties (hydraulic conductivity). Enthalpy balance theory explains a broad spectrum of observed surging behaviour in a single framework, and offers an answer to the wider question of why the majority of glaciers do not surge.