Ischemia or hypoxia‑induced myocardial injury is closely associated with oxidative stress. Scavenging free radicals and/or enhancing endogenous antioxidative defense systems may be beneficial for the impediment of myocardial ischemic injury. Hydrogen (H2) gas, as a water‑ and lipid‑soluble small molecule, is not only able to selectively eliminate hydroxyl (·OH) free radicals, but also to enhance endogenous antioxidative defense systems in rat lungs and arabidopsis plants. However, thus far, it has remained elusive whether H2 gas protects cardiomyocytes through enhancement of endogenous antioxidative defense systems. In the present study, the cardioprotective effect of H2 gas against ischemic or hypoxic injury was investigated, along with the underlying molecular mechanisms. H9c2 cardiomyoblasts (H9c2 cells) were treated in vitro with a chemical hypoxia inducer, cobalt chloride (CoCl2), to imitate hypoxia, or by serum and glucose deprivation (SGD) to imitate ischemia. Cell viability and intracellular ·OH free radicals were assessed. The role of an endogenous antioxidative defense system, the NF‑E2‑related factor 2 (Nrf2)/heme oxygenase 1 (HO‑1) signaling pathway, was evaluated. The findings revealed that treatment with CoCl2 or SGD markedly reduced cell viability in H9c2 cells. H2 gas‑rich medium protected against cell injury induced by SGD, but not that induced by CoCl2. When the cells were exposed to SGD, levels of intracellular ·OH free radicals were markedly increased; this was mitigated by H2 gas‑rich medium. Exposure of the cells to SGD also resulted in significant increases in HO‑1 expression and nuclear Nrf2 levels, and the HO‑1 inhibitor ZnPP IX and the Nrf2 inhibitor brusatol aggravated SGD‑induced cellular injury. H2 gas‑rich medium enhanced SGD‑induced upregulation of HO‑1 and Nrf2, and the HO‑1 or Nrf2 inhibition partially suppressed H2 gas‑induced cardioprotection. Furthermore, following genetic silencing of Nrf2 by RNA interference, the effects of H2 gas on the induction of HO‑1 and cardioprotection were markedly reduced. In conclusion, H2 gas protected cardiomyocytes from ischemia‑induced myocardial injury through elimination of ·OH free radicals and also through activation of the Nrf2/HO‑1 signaling pathway.