A Stirling engine is a heat engine that operates by cyclic compression and expansion of air or other gas at different temperatures, such that there is a net conversion of heat energy to mechanical work.