We investigate the evolution of the star formation rate (SFR)–density relation in the Extended Chandra Deep Field South and the Great Observatories Origin Deep Survey fields up to z ∼ 1.6. In addition to the ‘traditional method’, in which the environment is defined according to a statistical measurement of the local galaxy density, we use a ‘dynamical’ approach, where galaxies are classified according to three different environment regimes: group, ‘filament-like’ and field. Both methods show no evidence of an SFR–density reversal. Moreover, group galaxies show a mean SFR lower than other environments up to z ∼ 1, while at earlier epochs group and field galaxies exhibit consistent levels of star formation (SF) activity. We find that processes related to a massive dark matter halo must be dominant in the suppression of the SF below z ∼ 1, with respect to purely density-related processes. We confirm this finding by studying the distribution of galaxies in different environments with respect to the so-called main sequence (MS) of star-forming galaxies. Galaxies in both group and ‘filament-like’ environments preferentially lie below the MS up to z ∼ 1, with group galaxies exhibiting lower levels of star-forming activity at a given mass. At z > 1, the star-forming galaxies in groups reside on the MS. Groups exhibit the highest fraction of quiescent galaxies up to z ∼ 1, after which group, ‘filament-like’ and field environments have a similar mix of galaxy types. We conclude that groups are the most efficient locus for SF quenching. Thus, a fundamental difference exists between bound and unbound objects, or between dark matter haloes of different masses