Heat engines are based on the physical realization of a thermodynamic cycle, most famously the liquid-vapour Rankine cycle used for steam engines. Here we present a sublimation heat engine, which can convert temperature differences into mechanical work via the Leidenfrost effect. Through controlled experiments, quantified by a hydrodynamic model, we show that levitating dry-ice blocks rotate on hot turbine-like surfaces at a rate controlled by the turbine geometry, temperature difference and solid material properties. The rotational motion of the dry-ice loads is converted into electric power by coupling to a magnetic coil system. We extend our concept to liquid loads, generalizing the realization of the new engine to both sublimation and the instantaneous vapourization of liquids. Our results support the feasibility of low-friction in situ energy harvesting from both liquids and ices. Our concept is potentially relevant in challenging situations such as deep drilling, outer space exploration or micro-mechanical manipulation.