The old, red stars that constitute the bulges of galaxies, and the massive black holes at their centres, are the relics of a period in cosmic history when galaxies formed stars at remarkable rates and active galactic nuclei (AGN) shone brightly as a result of accretion onto black holes. It is widely suspected, but unproved, that the tight correlation between the mass of the black hole and the mass of the stellar bulge1 results from the AGN quenching the surrounding star formation as it approaches its peak luminosity. X-rays trace emission from AGN unambiguously, whereas powerful star-forming galaxies are usually dust-obscured and are brightest at infrared and submillimetre wavelengths. Here we report submillimetre and X-ray observations that show that rapid star formation was common in the host galaxies of AGN when the Universe was 2–6 billion years old, but that the most vigorous star formation is not observed around black holes above an X-ray luminosity of 1044 ergs per second. This suppression of star formation in the host galaxy of a powerful AGN is a key prediction of models in which the AGN drives an outflow, expelling the interstellar medium of its host and transforming the galaxy’s properties in a brief period of cosmic time.