We report the results of ab initio density functional theory calculations of the NMR chemical shift of liquid water and hexagonal ice. Depending on the structural model used, the calculated isotropic shift of ice Ih with respect to the gas phase is −8.0 ± 0.2 or −8.1 ± 0.1 ppm for the proton, and −48.6 ± 0.02 or −48.1 ± 0.02 ppm for oxygen. The proton anisotropy is −33.4 ± 0.2 or −33.6 ± 0.2 ppm. Using snapshots from ab initio molecular dynamics simulations, we find a gas-to-liquid shift of −5.8 ± 0.1 ppm for hydrogen, and −36.6 ± 0.5 ppm for oxygen. Molecules beyond the first solvation shell influence the proton chemical shift predominantly via the electric field generated by their permanent electric dipole moment. Finally, we show that it is possible to reproduce the proton chemical shifts in the condensed phases by an empirical function of the local molecular geometry.