We use the final data of the VIMOS Public Extragalactic Redshift Survey (VIPERS) to investigate the effect of the environment on the evolution of galaxies between z = 0.5 and z = 0.9. We characterise local environment in terms of the density contrast smoothed over a cylindrical kernel, the scale of which is defined by the distance to the fifth nearest neighbour. This is performed by using a volume-limited sub-sample of galaxies complete up to z = 0.9, but allows us to attach a value of local density to all galaxies in the full VIPERS magnitude-limited sample to i < 22.5. We use this information to estimate how the distribution of galaxy stellar masses depends on environment. More massive galaxies tend to reside in higher-density environments over the full redshift range explored. Defining star-forming and passive galaxies through their (NUV−r) vs. (r − K) colours, we then quantify the fraction of star-forming over passive galaxies, f ap , as a function of environment at fixed stellar mass. f ap is higher in low-density regions for galaxies with masses ranging from log(M/M ) = 10.38 (the lowest value explored) to at least log(M/M ) ∼ 11.3, although with decreasing significance going from lower to higher masses. This is the first time that environmental effects on high-mass galaxies are clearly detected at redshifts as high as z ∼ 0.9. We compared these results to VIPERS-like galaxy mock catalogues based on a widely used galaxy formation model. The model correctly reproduces f ap in low-density environments, but underpredicts it at high densities. The discrepancy is particularly strong for the lowest-mass bins. We find that this discrepancy is driven by an excess of low-mass passive satellite galaxies in the model. In high-density regions, we obtain a better (although not perfect) agreement of the model f ap with observations by studying the accretion history of these model galaxies (that is, the times when they become satellites), by assuming either that a non-negligible fraction of satellites is destroyed, or that their quenching timescale is longer than ∼2 Gyr.