The abundances of highly siderophile (iron-loving) elements (HSEs) in the Earth's mantle provide important constraints on models of the Earth's early evolution. It has long been assumed that the relative abundances of HSEs should reflect the composition of chondritic meteorites - which are thought to represent the primordial material from which the Earth was formed. But the non-chondritic abundance ratios recently found in several types of rock derived from the Earth's mantle have been difficult to reconcile with standard models of the Earth's accretion, and have been interpreted as having arisen from the addition to the primitive mantle of either non-chondritic extraterrestrial material or differentiated material from the Earth's core. Here we report in situ laser-ablation analyses of sulphides in mantle-derived rocks which show that these sulphides do not have chondritic HSE patterns, but that different generations of sulphide within single samples show extreme variability in the relative abundances of HSEs. Sulphides enclosed in silicate phases have high osmium and iridium abundances but low Pd/Ir ratios. Whereas pentlandite-dominated interstitial sulphides show low osmium and iridium abundances and high Pd/Ir ratios. We interpret the silicate-enclosed sulphides as the residues of melting processes and interstitial sulphides as the crystallization products of sulphide-bearing (metasomatic) fluids. We suggest that non-chondritic HSE patterns directly reflect processes occurring in the upper mantle - that is, melting and sulphide addition via metasomatism - and are not evidence for the addition of core material or of 'exotic' meteoritic components.