The most striking geological feature of the Moon is the terrain and elevation dichotomy1 between the hemispheres: the nearside is low and flat, dominated by volcanic maria, whereas the farside is mountainous and deeply cratered. Associated with this geological dichotomy is a compositional and thermal variation2,3, with the nearside Procellarum KREEP (potassium/rare-earth element/phosphorus) Terrane and environs interpreted as having thin, compositionally evolved crust in comparison with the massive feldspathic highlands. The lunar dichotomy may have been caused by internal effects (for example spatial variations in tidal heating4, asymmetric convective processes5 or asymmetric crystallization of the magma ocean6) or external effects (such as the event that formed the South Pole/Aitken basin1 or asymmetric cratering7). Here we consider its origin as a late carapace added by the accretion of a companion moon. Companion moons are a common outcome of simulations8 of Moon formation from a protolunar disk resulting from a giant impact, and although most coplanar configurations are unstable9, a ∼1,200-km-diameter moon located at one of the Trojan points could be dynamically stable for tens of millions of years after the giant impact10. Most of the Moon’s magma ocean would solidify on this timescale11,12, whereas the companion moon would evolve more quickly into a crust and a solid mantle derived from similar disk material, and would presumably have little or no core. Its likely fate would be to collide with the Moon at ∼2–3 km s−1, well below the speed of sound in silicates. According to our simulations, a large moon/Moon size ratio (∼0.3) and a subsonic impact velocity lead to an accretionary pile rather than a crater, contributing a hemispheric layer of extent and thickness consistent with the dimensions of the farside highlands1,13 and in agreement with the degree-two crustal thickness profile4. The collision furthermore displaces the KREEP-rich layer to the opposite hemisphere, explaining the observed concentration2,3.