AbstractAs-cast ZK40, ZK40-2Gd and ZK40-2Nd Mg alloys were investigated by in situ synchrotron radiation diffraction during compression at elevated temperature. The addition of rare earth elements increased the compressive yield strength from 23 MPa in the ZK40 alloy up to 40 MPa in the alloy with Nd or Gd. The azimuthal angle–time plots and electron back scattered diffraction maps from the compressed samples reveal that all the three alloys deform by grain rotation and crystallographic slip to obtain the final texture after compression. Continuous dynamic recrystallization played an important role in the ZK40 alloy during deformation, while twinning was not dominant. Discontinuous dynamic recrystallization was observed in the ZK40-2Gd. In the ZK40-2Gd and ZK40-2Nd alloys twinning also plays an important role during deformation at 350 °C. It is proposed that the pinning of the grain boundaries by the intermetallic phases was a main factor responsible for the observed differences in the deformation behavior.