Alpha-type Stirling engine. There are two cylinders. The expansion cylinder (red) is maintained at a high temperature while the compression cylinder (blue) is cooled. The passage between the two cylinders contains the regenerator.
Beta-type Stirling engine, with only one cylinder, hot at one end and cold at the other. A loose-fitting displacer shunts the air between the hot and cold ends of the cylinder. A power piston at the open end of the cylinder drives the flywheel.

A Stirling engine is a heat engine that is operated by a cyclic compression and expansion of air or other gas (the working fluid) at different temperatures, resulting in a net conversion of heat energy to mechanical work.[1][2] More specifically, the Stirling engine is a closed-cycle regenerative heat engine with a permanent gaseous working fluid. Closed-cycle, in this context, means a thermodynamic system in which the working fluid is permanently contained within the system, and regenerative describes the use of a specific type of internal heat exchanger and thermal store, known as the regenerator. Strictly speaking, the inclusion of the regenerator is what differentiates a Stirling engine from other closed cycle hot air engines.[3]

Originally conceived in 1816[4] as an industrial prime mover to rival the steam engine, its practical use was largely confined to low-power domestic applications for over a century.[5]