[en] The escape probability method developed by Sobolev (1947) is applied to the case of a two-level atom. The numerical applications are based on a previous work concerning a general theory of spectral-line formation in outward-accelerating and outward-decelerating stellar envelopes. Only the radiative exchanges occurring between the atomic levels are considered, and the statistical-equilibrium equations are solved rigorously in the cases of a transparent medium at rest, an outward-accelerating envelope, and an outward-decelerating envelope. The population of the atomic levels are compared for different physical conditions in each case. It is shown numerically that in the case of an outward-decelerating envelope the contribution of distant atoms to the mean intensity of line radiation appreciably enhances the degree of excitation throughout the envelope.