First-principles shear tests were performed on pure Mg, Mg–Li, Mg–Ca, Mg–Al, Mg–Sn, Mg–Ag, and Mg–Zn models to investigate the mechanical and chemical effects of the solute elements on the generalized stacking fault energy (GSFE) of Mg. The mechanical effect increased the unstable stacking fault energy (USFE), independent of the kind of solute element tested. The intensity of the mechanical effect was explained by the average distance between a solute atom and the surrounding Mg atoms, not by a difference in atomic radius between a solute atom and a Mg atom. In contrast, the chemical effect on the USFE was complicated, and the chemical effects of Ag and Zn were lower than expected from their electronegativity. Also, the chemical effect increased the USFE for the Li addition, but it decreased the USFE for the Ca addition although the electronegativity of Li is almost the same as that of Ca.