The intrinsic compression that arises in polycrystalline thin films under high atomic mobility conditions has been attributed to the insertion or trapping of adatoms inside grain boundaries. This compression is a consequence of the stress field resulting from imperfections in the solid and causes the thermomechanical fatigue that is estimated to be responsible for 90% of mechanical failures in current devices. We directly measure the local distribution of residual intrinsic stress in polycrystalline thin films on nanometer scales, using a pioneering method based on atomic force microscopy. Our results demonstrate that, at odds with expectations, compression is not generated inside grain boundaries but at the edges of gaps where the boundaries intercept the surface. We describe a model wherein this compressive stress is caused by Mullins-type surface diffusion towards the boundaries, generating a kinetic surface profile different from the mechanical equilibrium profile by the Laplace-Young equation. Where the curvatures of both profiles differ, an intrinsic stress is generated in the form of Laplace pressure. The Srolovitz-type surface diffusion that results from the stress counters the Mullins-type diffusion and stabilizes the kinetic surface profile, giving rise to a steady compression regime. The proposed mechanism of competition between surface diffusions would explain the flux and time dependency of compressive stress in polycrystalline thin films.