Context. The Rosetta spacecraft is escorting comet 67P/Churyumov-Gerasimenko from a heliocentric distance of >3.6 AU, where the comet activity was low, until perihelion at 1.24 AU. Initially, the solar wind permeates the thin comet atmosphere formed from sublimation. Aims. Using the Rosetta Plasma Consortium Ion Composition Analyzer (RPC-ICA), we study the gradual evolution of the comet ion environment, from the first detectable traces of water ions to the stage where cometary water ions accelerated to about 1 keV energy are abundant. We compare ion fluxes of solar wind and cometary origin. Methods. RPC-ICA is an ion mass spectrometer measuring ions of solar wind and cometary origins in the 10 eV-40 keV energy range. Results. We show how the flux of accelerated water ions with energies above 120 eV increases between 3.6 and 2.0 AU. The 24 h average increases by 4 orders of magnitude, mainly because high-flux periods become more common. The water ion energy spectra also become broader with time. This may indicate a larger and more uniform source region. At 2.0 AU the accelerated water ion flux is frequently of the same order as the solar wind proton flux. Water ions of 120 eV-few keV energy may thus constitute a significant part of the ions sputtering the nucleus surface. The ion density and mass in the comet vicinity is dominated by ions of cometary origin. The solar wind is deflected and the energy spectra broadened compared to an undisturbed solar wind. Conclusions. The flux of accelerated water ions moving from the upstream direction back toward the nucleus is a strongly nonlinear function of the heliocentric distance.