Understanding redox and photochemical reactions in aqueous environments requires a precise knowledge of the ionization potential and electron affinity of liquid water. The former has been measured, but not the latter. We predict the electron affinity of liquid water and of its surface from first principles, coupling path-integral molecular dynamics with ab initio potentials, and many-body perturbation theory. Our results for the surface (0.8 eV) agree well with recent pump-probe spectroscopy measurements on amorphous ice. Those for the bulk (0.1-0.3 eV) differ from several estimates adopted in the literature, which we critically revisit. We show that the ionization potential of the bulk and surface are almost identical; instead their electron affinities differ substantially, with the conduction band edge of the surface much deeper in energy than that of the bulk. We also discuss the significant impact of nuclear quantum effects on the fundamental gap and band edges of the liquid.