Earth grew through collisions with Moon-sized to Mars-sized planetary embryos from the inner Solar System, but it also accreted material from greater heliocentric distances1,2, including carbonaceous chondrite-like bodies, the likely source of Earth's water and highly volatile species3,4. Understanding when and how this material was added to Earth is critical for constraining the dynamics of terrestrial planet formation and the fundamental processes by which Earth became habitable. However, earlier studies inferred very different timescales for the delivery of carbonaceous chondrite-like bodies, depending on assumptions about the nature of Earth's building materials5-11. Here we show that the Mo isotopic composition of Earth's primitive mantle falls between those of the non-carbonaceous and carbonaceous reservoirs12-15, and that this observation allows us to quantify the accretion of carbonaceous chondrite-like material to Earth independently of assumptions about its building blocks. As most of the Mo in the primitive mantle was delivered by late-stage impactors10, our data demonstrate that Earth accreted carbonaceous bodies late in its growth history, probably through the Moon-forming impact. This late delivery of carbonaceous material probably resulted from an orbital instability of the gas giant planets, and it demonstrates that Earth's habitability is strongly tied to the very late stages of its growth.