It has long been recognized that the observation of γ rays originating from nuclear deexcitation can be exploited to identify neutral-current neutrino-nucleus interactions in water-Cherenkov detectors. We report the results of a calculation of the neutrino- and antineutrino-induced γ-ray production cross section for the oxygen target. Our analysis is focused on the kinematical region of neutrino energy larger than ∼200 MeV, in which a single-nucleon knockout is known to be the dominant reaction mechanism. The numerical results have been obtained using for the first time a realistic model of the target spectral function, extensively tested against electron-nucleus scattering data. We find that at a neutrino energy of 600 MeV the fraction of neutral-current interactions leading to emission of γ rays of energy larger than 6 MeV is ∼41%, and that the contribution of the p_{3/2} state is overwhelming.