© 2018 Acta Materialia Inc. Alloying magnesium (Mg) with rare earth elements such as yttrium (Y) has been reported to activate the pyramidal slip systems and improve the plasticity of Mg at room temperature. However, the origins of such dislocations and their dissociation mechanisms remain poorly understood. Here, we systematically investigate these mechanisms using dispersion-inclusive density-functional theory, in combination with molecular dynamics simulations. We find that dislocations form more readily on the pyramidal I plane than on the pyramidal II plane in Mg. The addition of Y atoms in Mg facilitates the dissociation of dislocations on pyramidal II, leading to the easier formation of the pyramidal II than pyramidal I in Mg-Y alloy. Importantly, in pyramidal II slip plane, a flat potential-energy surface (PES) exists around the position of stable stacking fault energy (SFE), which allows cooperative movement of atoms within the slip plane. Alloying Mg with Y atoms increases the range of the PES, and ultimately promotes different sliding pathways in the Mg-Y alloy. These findings are consistent with experimentally observed activation of the pyramidal II slip system in Mg-Y alloys, and provide important insight into the relationship between dislocation structure and macroscopic enhancement of plasticity.