In this work, we employed the first-principles calculations to explore the structural stability, elastic modulus, and electronic behavior of the Mg-Al-X (X=Sn, Pb) ternary compounds. The calculated formation enthalpy indicates that the Mg16Al12Sn-C exhibits the best stability with a value of -0.057 eV/atom. Moreover, the Mg16Al12Pb-C possesses the highest modulus values with values of 58.37, 52.32, and 120.86 GPa for bulk, shear, and Young's modulus, respectively. The Mg16Al12Sn-C exhibits weak anisotropy of the lowest AU value of 0.04. Additionally, the Mg16Al12Pb-C possesses the largest melting temperature of 1142.85 K. The high modulus of the Mg16Al12Pb-C can be attributed to the contributions from the Al-Al and Mg-Al bonds. Moreover, the weighted average bond length results show that the Mg16Al12Pb-C (Mg16Al12Sn-C) in the Mg-Al-Pb (Mg-Al-Sn) system possesses the shortest bond length value of 3.067 & Aring; (3.058 & Aring;), resulting in a higher modulus.