It is demonstrated that the linear Bloch equations, describing near-resonant excitation of two-level media with relaxation, can be resolved into a 3 n-dimensional nonlinear system associated with a special spectral problem, generalizing the classical Zakharov Shabat spectral problem. Remarkably, for n = 1 it is the well-known Lorenz system, and for n > 1 several such systems coupled with each other in a manner dependant on the excitation pulse. The unstable manifold of a saddle equilibrium point in this ensemble characterizes possible excitations of the spins from the initial equilibrium state. This enables us to get a straightforward geometric extension of the inverse scattering method to the damped Bloch equations and hence invert them, i.e., design frequency selective pulses automatically compensated for the effect of relaxation. The latter are essential, for example, in nuclear magnetic resonance and extreme nonlinear optics.