Twinning and detwinning behavior of a commercial AZ31 magnesium alloy during cyclic compression–tension deformation with a total strain amplitude of 4% (±2%) was evaluated using the complementary techniques of in-situ neutron diffraction, identical area electron backscatter diffraction, and transmission electron microscopy. In-situ neutron diffraction demonstrates that the compressive deformation was dominated by twin nucleation, twin growth, and basal slip, while detwinning dominated the unloading of compressive stresses and subsequent tension stage. With increasing number of cycles from one to eight: the volume fraction of twins at -2% strain gradually increased from 26.3% to 43.5%; the residual twins were present after 2% tension stage and their volume fraction increased from zero to 3.7% as well as a significant increase in their number; and the twinning spread from coarse grains to fine grains involving more grains for twinning. The increase in volume fraction and number of residual twins led to a transition from twin nucleation to twin growth, resulting in a decrease in yield strength of compression deformation with increasing cycles. A large number of < c >-component dislocations observed in twins and the detwinned regions were attributed to the dislocation transmutation during the twinning and detwinning. The accumulation of barriers including twin boundaries and various types of dislocations enhanced the interactions of migrating twin boundary with these barriers during twinning and detwinning, which is considered to be the origin for increasing the work hardening rate in cyclic deformation of the AZ31 alloy.