We study the contribution of galaxies with different properties to the global densities of star formation rate (SFR), atomic (H I) and molecular hydrogen (H2) as a function of redshift. We use the GALFORM model of galaxy formation, which is set in the cold dark matter (λCDM) framework. This model includes a self-consistent calculation of the SFR, which depends on the H2 content of galaxies. The predicted SFR density and how much of this is contributed by galaxies with different stellar masses and infrared luminosities are in agreement with observations. The model predicts a modest evolution of the HI density at z <3, which is also in agreement with the observations. The HI density is predicted to be always dominated by galaxies with SFR <1M⊙ yr-1. This contrasts with the H2 density, which is predicted to be dominated by galaxies with SFR >10M⊙ yr-1 at z > 1. Current high-redshift galaxy surveys are limited to detect carbon monoxide in galaxies with SFR ≥ 30 M⊙ yr-1, which in our model make up, at most, 20 per cent of the H2 in the universe. In terms of stellar mass, the predicted H2 density is dominated by massive galaxies, Mstellar > 1010M⊙, while the HI density is dominated by low-mass galaxies, Mstellar <109M⊙. In the context of upcoming neutral gas surveys, we suggest that the faint nature of the galaxies dominating the HI content of the Universe will hamper the identification of optical counterparts, while for H2, we expect follow-up observations of molecular emission lines of already existing galaxy catalogues to be able to uncover the H2 density of the Universe. © 2014 The Authors Published by Oxford University Press on behalf of the Royal Astronomical Society.