We study the influence of restriction on Carr-Purcell-Meiboom-Gill spin echo response of magnetization of spins diffusing in a bounded region in the presence of a nonuniform magnetic field gradient. We consider two fields in detail-a parabolic field which, like the uniform-gradient field, scales with the system size, and a cosine field which remains bounded. Corresponding to three main length scales, the pore size, L(S), the dephasing length, L(G), and the diffusion length during half-echo time, L(D), we identify three main regimes of decay of the total magnetization: motionally averaged, localization, and short-time. In the short-time regime (L(D) << L(S), L(G)), we confirm that the leading order behavior is controlled by the average of the square of the gradient, (nablaB(z))(2), and in the motionally averaged regime (MAv), where L(S) << L(D), L(G), by (integral dxB(z))(2). We verify numerically that two different fields for which those two averages are identical result in very similar decay profiles not only in the limits of short and long times but also in the intermediate times, with important practical implications. In the motionally averaged regime we found that previous estimates of the decay exponent for the parabolic field, based on a soft-boundary condition, are significantly altered in the presence of a more realistic, hard wall. We find the scaling of the decay exponent in the MAv regime with pore size to be L(2)(S) for the cosine field and L(6)(S) for the parabolic field, as contrasted with the linear gradient scaling of L(4)(S). In the localization regime, for both the cosine and the parabolic fields, the decay exponent depends on a fractional power of the gradient, implying a breakdown of the second cumulant or the Gaussian phase approximation. We also examined the validity of time-evolving the total magnetization according to a distribution of effective local gradients and found that such approximation works well only in the short-time regime and breaks down strongly for long times. Copyright 2000 Academic Press.