- Slow dissipation of non-potential magnetic fields in the magnetosphere of the magnetar is assumed to accelerate particles to hundreds MeV along the magnetic field lines. We consider interaction of fast particles with the surface of the magnetar. We argue that the collisionless dissipation does not work in the atmosphere of the neutron star because the two-stream instability is stabilized by the inhomogeneity of the atmosphere. Rather, the dominant dissipation mechanism is collisional Landau levelexcitations followed by pair production via the deexcitation gamma-rays ultimately leading to electrons with the energy below the Landau energy. We show that, because of the effects of the superstrong magnetic field, these electrons could emerge from the surface carrying most of the original energy so that a hot corona arises with the temperature of 1 - 2 MeV. This extended corona is better suited than a thin atmosphere to convert most of the primary beam energy to non-thermal radiation and, as we show, most of the coronal energy release is radiated away in the hard X-ray and the soft gamma-ray bands by Comptonization and bremsstrahlung. The radiation spectrum is a power-law with the photon index $1<\alpha<2$. The model may account for the persistent hard X-ray emission discovered recently from the soft gamma-ray repeaters and anomalous X-ray pulsars and predicts that the radiation spectrum is extended into the MeV band.