Porphyry copper deposits - the primary source of the world's copper - are a consequence of the degassing of intrusion complexes in magmatic arcs associated with ancient subduction zones. They are characterized by copper and iron sulphides, commonly found with anhydrite (CaSO4), over scales of several kilometres through intensely altered and fractured rocks. The magmatic source of the metals is broadly understood, but the processes that transport and deposit the metals at the megaton scale are unclear. The hydrogen sulphide necessary for metal deposition is commonly assumed to form by a reaction between sulphur dioxide and water, but this reaction is inefficient and cannot explain the formation of economic-grade deposits. Here we use high-temperature laboratory experiments to show that a very rapid chemisorption reaction occurs between sulphur dioxide gas, a principal component of magmatic gas mixtures, and calcic feldspar, an abundant mineral in the arc crust. The chemisorption reaction generates the mineral anhydrite and hydrogen sulphide gas, and triggers deposition of metal sulphides. We use thermodynamic calculations to show that as magmatic gas cools and expands the concentration of hydrogen sulphide gas increases exponentially to drive efficient deposition of metal sulphides and consequent formation of economic-grade porphyry copper deposits.