Hydrogen being a cleaner energy carrier has increased the importance of hydrogen-containing light metal hydrides, in particular those with large gravimetric hydrogen density like magnesium hydride (MgH 2). In this study, density functional and density functional perturbation theories are combined to investigate the structural, elastic, thermodynamic, electronic and optical properties of MgH 2. Our structural parameters calculated with those proposed by Perdew, Burke and Ernzerof generalized gradient approximation (PBE-GGA) and Wu–Cohen GGA (WC-GGA) are in agreement with experimental measurements, however the underestimated band gap values calculated using PBE-GGA and WC-GGA were greatly improved with the GGA suggested by Engle and Vosko and the modified Becke–Johnson exchange correlation potential by Trans and Blaha. As for the thermodynamic properties the specific heat values at low temperatures were found to obey the T 3 rule and at higher temperatures Dulong and Petit's law. Our analysis of the optical properties of MgH 2 also points to its potential application in optoelectronics.