Molecular dynamics (MD) and Monte Carlo (MC) methods are used to determine the spin-pair correlation function G(*)(t) for the diffusion of bulk water in three dimensions (3D) and pore water in two dimensions (2D) and quasi-two dimensions (Q2D). The correlation function is required for the determination of the nuclear magnetic resonance spin-lattice and spin-spin relaxation times T(1) and T(2). It is shown that the analytic form of the powder-average correlation function, introduced by Sholl [Sholl, J. Phys. C: Solid State Phys. 7, 3378 (1974)] for the diffusion of spins on a 3D lattice, is of general validity. An analytic expression for G(*)(t) for a uniform spin fluid is derived in 2D. An analytic expression for the long-time behavior of G(*)(t) is derived for spins diffusing on 3D, 2D, and Q2D lattices. An analytic correction term, which accounts for spin pairs outside the scope of the numerical simulations, is derived for 3D and 2D and shown to improve the accuracy of the simulations. The contributions to T(1) due to translational and rotational motion obtained from the MD simulation of bulk water at 300 K are 7.4 s and 10±1 s, respectively, at 150 MHz, leading to an overall time of 4.3±0.4 s compared to the experimental value of 3.8 s. In Q2D systems, in which water is confined by alpha-quartz surfaces to thicknesses of 1-5 nm, T(1) for both translational and rotational relaxation is reduced due to the orientation and adsorption of spins at the surfaces. A method of parametrizing the MC lattice-diffusion simulations in 3D, 2D, and Q2D systems is presented. MC results for G(*)(t) for 3D and 2D systems are found to be consistent with an analytic uniform fluid model for t~/>40 ps. The value of TT(1) for translational diffusion obtained from the MC simulation of bulk water is found to be 4.8 s at 15 MHz. G(*)(t) obtained from MC simulations of Q2D systems, where water is confined by hard walls, is found to execute a distinct transition from 3D to 2D behavior. The T(1) is found to be similar to the 3D bulk water result at all pore thicknesses.