Observations at submillimetre and X-ray wavelengths show that rapid star formation was common in the host galaxies of active galactic nuclei when the Universe was 2–6 Gyr old, but that the most vigorous star formation is not observed around powerful black holes, thereby confirming a key prediction of models in which an active galactic nucleus expels the interstellar medium of its host galaxy.