  Magnetospheres of neutron stars are anchored in the rigid crust and can be
twisted by sudden crustal motions ("starquakes"). The twisted magnetosphere
does not remain static and gradually untwists, dissipating magnetic energy and
producing radiation. The equation describing this evolution is derived, and its
solutions are presented. Two distinct regions coexist in untwisting
magnetospheres: a potential region where curl(B)=0 ("cavity") and a
current-carrying bundle of field lines ("j-bundle"). The cavity has a sharp
boundary, which expands with time and eventually erases all of the twist. In
this process, the electric current of the j-bundle is sucked into the star.
Observational appearance of the untwisting process is discussed. A hot spot
forms at the footprints of the j-bundle. The spot shrinks with time toward the
magnetic dipole axis, and its luminosity and temperature gradually decrease. As
the j-bundle shrinks, the amplitude of its twist can grow to the maximum
possible value ~ 1. The strong twist near the dipole axis increases the
spindown rate of the star and can generate a broad beam of radio emission. The
model explains the puzzling behavior of magnetar XTE J1810-197 -- a canonical
example of magnetospheric evolution following a starquake. We also discuss
implications for other magnetars. The untwisting theory suggests that the
nonthermal radiation of magnetars is preferentially generated on a bundle of
extended closed field lines near the dipole axis.
