We study the chemical properties of the stellar populations in eight simulations of the formation of Milky Way mass galaxies in a Λ cold dark matter universe. Our simulations include metal-dependent cooling and an explicitly multiphase treatment of the effects on the gas of cooling, enrichment and supernova feedback. We search for correlations between formation history and chemical abundance patterns. Differing contributions to spheroids and discs from in situ star formation and from accreted populations are reflected in differing chemical properties. Discs have younger stellar populations, with most stars forming in situ and with low α-enhancement from gas which never participated in a galactic outflow. Up to 15 per cent of disc stars can come from accreted satellites. These tend to be α-enhanced, older and to have larger velocity dispersions than the in situ population. Inner spheroids have old, metal-rich and α-enhanced stars which formed primarily in situ, more than 40 per cent from material recycled through earlier galactic winds. Few accreted stars are found in the inner spheroid unless a major merger occurred recently. Such stars are older, more metal-poor and more α-enhanced than the in situ population. Stellar haloes tend to have low metallicity and high α-enhancement. The outer haloes are made primarily of accreted stars. Their mean metallicity and α-enhancement reflect the masses of the disrupted satellites where they formed: more massive satellites typically have higher [Fe/H] and lower [α/Fe]. Surviving satellites have distinctive chemical patterns which reflect their extended, bursty star formation histories. These produce lower α-enhancement at given metallicity than in the main galaxy, in agreement with observed trends in the Milky Way.