The NMR dephasing behavior of the nuclear spins of a fluid confined in a porous material can be investigated by Hahn spin echoes. Previous experimental results on water in a magnetically doped clay have shown a nonmonoexponentially decaying magnetization, which can be understood neither by the known dephasing rate of freely diffusing spins in a uniform gradient nor by spins diffusing in a restricted geometry. For a better understanding of NMR measurements on these systems, a systematic survey was performed of the various length scales that are involved. The standard length scales for the situation of a uniform gradient are diffusing length, structure length, and dephasing length. We show that for a nonuniform gradient, a new length scale has to be introduced: the magnetic-field curvature length. When a particle diffuses less than this length scale, it experiences a local uniform gradient. In that case the spin-echo decay can be described by the so-called local gradient approximation (LGA). When a particle diffuses over a longer distance than the structure length, the spin-echo decay can be described by the motional averaging regime. For both regimes, scaling laws are derived. In this paper, a random-walk model is used to simulate the dephasing effect of diffusing spins in a spherical pore in the presence of a magnetic dipole field. By varying the dipole magnitude, situations can be created in which the dephasing behavior scales according to the motional averaging regime or according to the LGA regime, for certain ranges of echo times. Two model systems are investigated: a spherical pore in the vicinity of a magnetic point dipole and a spherical pore adjacent to a magnetic dipolar grain of the same size as the pore. The simulated magnetization decay curves of both model systems confirm the scaling laws. The LGA, characterized by a nonmonoexponential magnetization decay, is also investigated by calculating the spatially resolved magnetization in the pore. For this regime, the magnetization is found to be inhomogeneously distributed within the pore, whereas it is homogeneously distributed in the motional averaging regime.