The structures and properties of hydrogen storage alloy Mg 2Ni, of aluminum and silver substituted alloys Mg 2− x M x Ni (M = Al and Ag, x = 0.16667), and of their hydrides Mg 2NiH 4, Mg 2− x M x NiH 4 (M = Al and Ag, x = 0.125) have been calculated from first-principles. Results show that the primitive cell sizes of the intermetallic alloys and hydrides were reduced by substitution of Mg with Al or Ag. Also, the interaction of Ni–Ni was weakened by the substitution. A strong covalent interaction between H and Ni atoms forms tetrahedral NiH 4 units in Mg 2NiH 4. The NiH 4 unit near the Al/Ag atom became tripod-like NiH 3 in Mg 2− x M x NiH 4 (M = Al, Ag), indicating that the hydrogen storage capacity was decreased by the substitution. The calculated enthalpies of hydrogenation for Mg 2Ni, Mg 2− x Al x Ni and Mg 2− x Ag x Ni are −65.14, −51.56 and −53.63 kJ/mol H 2, respectively, implying that the substitution destabilizes the hydrides. Therefore, the substitution is an effective technique for improving the thermodynamic behavior of hydrogenation/dehydrogenation in magnesium-based hydrogen storage materials.