Magmas enriched in Cu and Au are likely to be the most prospective for magmatic–hydrothermal deposits of these metals. However, the mechanism that leads to the formation of metal-rich magmas is not well constrained. We report major, trace and platinum group element (PGE) data for the Niuatahi–Motutahi lavas, Tonga rear arc, with the aim of studying their petrogenesis with special emphasis on the evolution of chalcophile elements during magmatic differentiation. Major and trace element contents, including S and Cl, were also measured in glasses, phenocrysts and melt inclusions to complement the whole-rock data. The Niuatahi–Motutahi lavas are associated with Cu and Au mineralization and therefore provide an opportunity to investigate the characteristics of an ore-associated magmatic system. They show a wide compositional variation from basalts to dacites with MgO contents that vary between ∼14 and 1 wt %. The dacites can be subdivided into high-K and low-K dacites. Geochemical modeling and their mineralogy suggest that the low-K dacites are comagmatic with the basalts and evolved by fractional crystallization. Copper, Au and Pd behave incompatibly in the basalts and andesitic glasses, whereas they become compatible in the low-K dacite. In contrast, Pt, Rh, Ru and Ir are moderately compatible in the basalts and correlate negatively with MgO, but become strongly compatible in the dacites. The Cu, Au and PGE trends can be explained by fractional crystallization of a Pt-rich alloy in the basalts and andesitic glasses, followed by sulfide saturation in the low-K dacites. The high-K dacites may have evolved from a slightly different magma source; however, their chalcophile elements fractionated in a similar manner. Chlorine and S data for melt inclusions and glasses from the basalts and dacites suggest that water-rich volatile saturation occurred during evolution of the dacites. The Niuatahi–Motutahi dacites were enriched in Cu from 80 to 200 ppm and in Au from <1 to 7 ppb by fractional crystallization as the magma evolved from basalt through andesite to dacite. We suggest that late sulfide saturation allowed Cu and Au to become enriched by a factor of two in the Niuatahi–Motutahi dacites before volatile saturation and that this played an important role in the formation of the Cu- and Au-rich mineralization. This sulfide saturation history contrasts with that of the Honshu arc volcanic rocks, Japan, where sulfide saturation occurred early. The Honshu arc volcanic rocks are not associated with porphyry Cu or Au deposits, which we suggest is due to loss of most of the Cu and Au to an early immiscible sulfide phase.