We realize a heat engine using a single-electron spin as a working medium. The spin pertains to the valence electron of a trapped 40Ca+ ion, and heat reservoirs are emulated by controlling the spin polarization via optical pumping. The engine is coupled to the ion’s harmonic-oscillator degree of freedom via spin-dependent optical forces.