  The recent observations of the anomalous X-ray pulsars 4U 0142+61 and 1RXS
J170849.0-400910 by the Imaging X-ray Polarimetry Explorer (IXPE) opened up a
new avenue to study magnetars, neutron stars endowed with superstrong magnetic
fields ($B\gtrsim 10^{14}$~G). The detected polarized X-rays from 4U 0142+61
exhibit a 90$^\circ$ linear polarization swing from low photon energies
($E\lesssim 4$~keV) to high energies ($E\gtrsim 5.5$~keV). We show that this
swing can be explained by photon polarization mode conversion at the vacuum
resonance in the magnetar atmosphere; the resonance arises from the combined
effects of plasma-induced birefringence and QED-induced vacuum birefringence in
strong magnetic fields. This explanation suggests that the atmosphere of 4U
0142 be composed of partially ionized heavy elements, and the surface magnetic
field be comparable or less than $10^{14}$~G, consistent with the dipole field
inferred from the measured spindown. It also implies that the spin axis of 4U
0142+61 is aligned with its velocity direction. The polarized X-rays from 1RXS
J170849.0-400910 do not show such $90^\circ$ swing, consistent with magnetar
atmospheric emission with $B\gtrsim 5\times 10^{14}$~G.
