Recent observations have shown that, only a billion years after the Big Bang, the Universe was already lit up by bright quasars fuelled by the infall of gas onto supermassive black holes. The masses of these early black holes are inferred from their luminosities to be >109 solar masses (M⊙), which is a difficult theoretical challenge to explain. Like nearby quasars, the early objects could have formed in the central cores of massive host galaxies. The formation of these hosts could be explained if, like local large galaxies, they were assembled gravitationally inside massive (>1012 M⊙) haloes of dark matter. There has hitherto been no observational evidence for the presence of these massive hosts or their surrounding haloes. Here we show that the cosmic gas surrounding each halo must respond to its strong gravitational pull, where absorption by the infalling hydrogen produces a distinct spectral signature. That signature can be seen in recent data.