We use deep Herschel observations taken with both PACS and SPIRE imaging cameras to estimate the dust mass of a sample of galaxies extracted from the GOODS-S, GOODS-N and the COSMOS fields. We divide the redshift-stellar mass (Mstar)-star formation rate (SFR) parameter space into small bins and investigate average properties over this grid. In the first part of the work we investigate the scaling relations between dust mass, stellar mass and SFR out to z = 2.5. No clear evolution of the dust mass with redshift is observed at a given SFR and stellar mass. We find a tight correlation between the SFR and the dust mass, which, under reasonableassumptions, is likely a consequence of the Schmidt-Kennicutt (S-K) relation. The previously observed correlation between the stellar content and the dust content flattens or sometimes disappears when considering galaxies with the same SFR. Our finding suggests that most of the correlation between dust mass and stellar mass obtained by previous studies is likely a consequence of the correlation between the dust mass and the SFR combined with the main sequence, i.e., the tight relation observed between the stellar mass and the SFR and followed by the majority of star-forming galaxies. We then investigate the gas content as inferred from dust mass measurements. We convert the dust mass into gas mass by assuming that the dust-to-gas ratio scales linearly with the gas metallicity (as supported by many observations). For normal star-forming galaxies (on the main sequence) the inferred relation between the SFR and the gas mass (integrated S-K relation) broadly agrees with the results of previous studies based on CO measurements, despite the completely different approaches. We observe that all galaxies in the sample follow, within uncertainties, the same S-K relation. However, when investigated in redshift intervals, the S-K relation shows a moderate, but significant redshift evolution. The bulk of the galaxy population at z ~ 2 converts gas into stars with an efficiency (star formation efficiency, SFE = SFR/Mgas, equal to the inverse of the depletion time) about 5 times higher than at z ~ 0. However, it is not clear what fraction of such variation of the SFE is due to an intrinsic redshift evolution and what fraction is simply a consequence of high-z galaxies having, on average, higher SFR, combined with the super-linear slope of the S-K relation (while other studies find a linear slope). We confirm that the gas fraction (fgas = Mgas/(Mgas + Mstar)) decreases with stellar mass and increases with the SFR. We observe no evolution with redshift once Mstarand SFR are fixed. We explain these trends by introducing a universal relation between gas fraction, stellar mass and SFR that does not evolve with redshift, at least out to z ~ 2.5. Galaxies move across this relation as their gas content evolves across the cosmic epochs. We use the 3D fundamental fgas-Mstar-SFR relation, along with the evolution of the main sequence with redshift, to estimate the evolution of the gas fraction in the average population of galaxies as a function of redshift and as a function of stellar mass: we find that Mstar â‰ 1011 M âŠ™ galaxies show the strongest evolution at z â‰ 1.3 and a flatter trend at lower redshift, while fgas decreases more regularly over the entire redshift range probed in M star â‰ 1011 M âŠ™ galaxies, in agreement with a downsizing scenario. © 2014 ESO.