Abundant molecular oxygen was discovered in the coma of comet 67P/Churyumov-Gerasimenko. Its origin was ascribed to primordial gaseous O2 incorporated into the nucleus during the comet's formation. This thesis was put forward after discounting several O2 production mechanisms in comets, including photolysis and radiolysis of water, solar wind-surface interactions and gas-phase collisions. Here we report an original Eley-Rideal reaction mechanism, which permits direct O2 formation in single collisions of energetic water ions with oxidized cometary surface analogues. The reaction proceeds by H2O+ abstracting a surface O-atom, then forming an excited precursor state, which dissociates to produce O2-. Subsequent photo-detachment leads to molecular O2, whose presence in the coma may thus be linked directly to water molecules and their interaction with the solar wind. This abiotic O2 production mechanism is consistent with reported trends in the 67P coma and raises awareness of the role of energetic negative ions in comets.