The energetics and electronic structure of the Ca alloying Mg 17Al12 phase have been calculated using a first principles pseudopotential plane-wave method based on the density functional theory. According to the calculation results, the negative heat of formation and the cohesive energy of (Mg17-xCax)Al12 (x = 0. 1, 4, 12) gradually increase when the Mg atoms at the I, II, III positions of the Mg17Al12 phase are substituted with Ca, which indicates that the alloying ability of (Mg17-xCax)A,)Al12 with the replacement of Ca for Mg(III) atoms is the strongest among the three substitutions and (Mg5Ca12)Al12 formed in this manner has the highest structural stability. After comparing the densities of states (DOS) for (Mg17-xCax)Al12 (x = 0. 1, 4, 12), it is found that the increase in the structural stability of Mg 17Al12 alloyed by Ca attributes to an increase in the bonding electron numbers at energy levels below the Fermi level, which mainly originates from the contribution of the valence electron numbers of Al (p) and Ca (s) orbitals.