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