  Magnetars are neutron stars with extremely strong magnetic fields, frequently
powering high-energy activity in X-rays. Pulsed radio emission following some
X-ray outbursts have been detected, albeit its physical origin is unclear. It
has long been speculated that the origin of magnetars' radio signals is
different from those from canonical pulsars, although convincing evidence is
still lacking. Five months after magnetar SGR 1935+2154's X-ray outburst and
its associated Fast Radio Burst (FRB) 20200428, a radio pulsar phase was
discovered. Here we report the discovery of X-ray spectral hardening associated
with the emergence of periodic radio pulsations from SGR 1935+2154 and a
detailed analysis of the properties of the radio pulses. The complex radio
pulse morphology, which contains both narrow-band emission and frequency
drifts, has not been seen before in other magnetars, but is similar to those of
repeating FRBs - even though the luminosities are many orders of magnitude
different. The observations suggest that radio emission originates from the
outer magnetosphere of the magnetar, and the surface heating due to the
bombardment of inward-going particles from the radio emission region is
responsible for the observed X-ray spectral hardening.
