Observations of cometary nuclei have revealed a very limited amount of surface water ice, which is insufficient to explain the observed water outgassing. This was clearly demonstrated on comet 9P/Tempel 1, where the dust jets (driven by volatiles) were only partially correlated with the exposed ice regions. The observations of 67P/Churyumov-Gerasimenko have revealed that activity has a diurnal variation in intensity arising from changing insolation conditions. It was previously concluded that water vapour was generated in ice-rich subsurface layers with a transport mechanism linked to solar illumination, but that has not hitherto been observed. Periodic condensations of water vapour very close to, or on, the surface were suggested to explain short-lived outbursts seen near sunrise on comet 9P/Tempel 1. Here we report observations of water ice on the surface of comet 67P/Churyumov-Gerasimenko, appearing and disappearing in a cyclic pattern that follows local illumination conditions, providing a source of localized activity. This water cycle appears to be an important process in the evolution of the comet, leading to cyclical modification of the relative abundance of water ice on its surface.