Temperate Earth-sized exoplanets around late-M dwarfs offer a rare opportunity to explore under which conditions planets can develop hospitable climate conditions. The small stellar radius amplifies the atmospheric transit signature, making even compact secondary atmospheres dominated by N2 or CO2 amenable to characterization with existing instrumentation1. Yet, despite large planet search efforts2, detection of low-temperature Earth-sized planets around late-M dwarfs has remained rare and the TRAPPIST-1 system, a resonance chain of rocky planets with seemingly identical compositions, has not yet shown any evidence of volatiles in the system3. Here we report the discovery of a temperate Earth-sized planet orbiting the cool M6 dwarf LP 791-18. The newly discovered planet, LP 791-18d, has a radius of 1.03 ± 0.04 R ⊕ and an equilibrium temperature of 300–400 K, with the permanent night side plausibly allowing for water condensation. LP 791-18d is part of a coplanar system4 and provides a so-far unique opportunity to investigate a temperate exo-Earth in a system with a sub-Neptune that retained its gas or volatile envelope. On the basis of observations of transit timing variations, we find a mass of 7.1 ± 0.7 M ⊕ for the sub-Neptune LP 791-18c and a mass of 0.9−0.4+0.5M⊕ for the exo-Earth LP 791-18d. The gravitational interaction with the sub-Neptune prevents the complete circularization of LP 791-18d’s orbit, resulting in continued tidal heating of LP 791-18d’s interior and probably strong volcanic activity at the surface5,6.