Although the proximity of the Andromeda galaxy (M31) offers an opportunity to understand how mergers affect galaxies1, uncertainty remains about M31's most important mergers. Previous studies focused individually on the giant stellar stream2 or the impact of M32 on M31's disk3,4, thereby suggesting many substantial satellite interactions5. Yet models of M31's disk heating6 and the similarity between the stellar populations of different tidal substructures in M31's outskirts7 both suggested a single large merger. M31's stellar halo (its outer low-surface-brightness regions) is built up from the tidal debris of satellites5 and provides information about its important mergers8. Here we use cosmological models of galaxy formation9,10 to show that M31's massive11 and metal-rich12 stellar halo, containing intermediate-age stars7, dramatically narrows the range of allowed interactions, requiring a single dominant merger with a large galaxy (with stellar mass about 2.5 × 1010 solar masses, M⊙ the third largest member of the Local Group) about 2 billion years (Gyr) ago. This single event explains many observations that were previously considered separately: M31's compact and metal-rich satellite M3213 is likely to be the stripped core of the disrupted galaxy, its rotating inner stellar halo14 contains most of the merger debris, and the giant stellar stream15 is likely to have been thrown out during the merger. This interaction may explain M31's global burst of star formation about 2 Gyr ago16 in which approximately a fifth of its stars were formed. Moreover, M31's disk and bulge were already in place, suggesting that mergers of this magnitude need not dramatically affect galaxy structure.