  Persistent activity of magnetars is associated with electric discharge that
continually injects relativistic particles into the magnetosphere. Large active
magnetic loops around magnetars must be filled with outflowing particles that
interact with radiation via resonant scattering and spawn electron-positron
pairs. The outflow energy is processed into copious e+- until the plasma enters
outer parts of the loop where the magnetic field is reduced below 10^13 G. In
the outer zone, photons scattered by the outflow do not convert to e+- pairs
and the outflow radiates its energy away. The escaping radiation forms a
distinct hard X-ray peak in the magnetar spectrum. It has the following
features: (1) Its luminosity L=10^35-10^36 erg/s can easily exceed the thermal
luminosity from the magnetar surface. (2) Its spectrum extends from 10 keV to
the MeV band with a hard spectral slope, which depends on the object
inclination to the line of sight. (3) The anisotropic hard X-ray emission
exhibits strong pulsations as the magnetar spins. (4) The emission spectrum
typically peaks around 1 MeV, but the peak position significantly oscillates
with the spin period. (5) The emission is dominated by the extraordinary
polarization mode at photon energies below 1 MeV. (6) The decelerated pairs
accumulate and annihilate at the top of the magnetic loop, and emit the 511-keV
line with luminosity L_ann\sim0.1L. Features (1)-(3) agree with available data;
(4)-(6) can be tested by future observations.
