In magic-angle-spinning solid-state NMR, the homonuclear J-couplings between pairs of spin-1/2 nuclei may be determined by studying the modulation of the spin echo induced by a pi-pulse, as a function of the echo duration. We present the theory of J-induced spin-echo modulation in magic-angle-spinning solids, and derive a set of modulation regimes which apply under different experimental conditions. In most cases, the dominant spin-echo modulation frequency is exactly equal to the J-coupling. Somewhat surprisingly, the chemical shift anisotropies and dipole-dipole couplings tend to stabilise--rather than abscure--the J-modulation. The theoretical conclusions are supported by numerical simulations and experimental results obtained for three representative samples containing 13C spin pairs.