A heat engine is a device that converts the heat energy from a high-temperature source into mechanical work or electricity. It operates based on the principles of thermodynamics, specifically the Second and Third Laws, to harness the flow of thermal energy and generate useful power.