Ghrelin is an endogenous ligand of growth hormone (GH) secretagogue receptor (GHSR) and has a number of biological effects, including heart protection. The present study aimed to reveal the positive effect of ghrelin on myocardium with hypoxia/reoxygenation (H/R) treatment and the involved molecular mechanisms. Successful construction of lentiviral expression vector (ghrelin-pLVX-Puro) was confirmed by colony polymerase chain reaction (PCR) verification. Primary rat cardiac myocytes were isolated and identified by immunofluorescence staining. Existence of red fluorescence of α-sarcomeric actinin indicated the successful isolation. Following ghrelin transfection and H/R treatment, primary cells were divided into four groups: Control, H/R, empty (empty pLVX-Puro + H/R) and ghrelin (ghrelin-pLVX-Puro + H/R). Cell viability and apoptosis were evaluated by Cell Counting Kit-8 (CCK-8) and Hoechst staining, respectively. The cell viability in the ghrelin group was significantly higher than that in the empty control group (P<0.05). The apoptosis rate in the ghrelin group was significantly lower than that in the empty control group (P<0.05). An ex vivo rat cardiac perfusion model was established. Following ghrelin incubation and H/R treatment, ex vivo myocardium was divided into four groups: Control, sham, H/R and ghrelin (ghrelin + H/R). Immunohistochemical analysis demonstrated that ghrelin increased the integrity of cardiac myocytes, and decreased shrinkage and apoptosis. mRNA and protein expression levels of GH, GHSR, insulin-like growth factor-1 (IGF-1), protein kinase B (Akt), phosphorylated Akt (p-Akt) were determined by reverse transcription (RT)-PCR, western blot analysis and immunohistochemical analysis. Ghrelin upregulated the mRNA and protein expression levels of GH, GHSR and IGF-1, and increased the ratio of p-Akt to Akt protein level (p-Akt/Akt) in cardiac myocytes and myocardial tissues with H/R treatment. In conclusion, ghrelin protected the myocardium with H/R treatment through upregulating the expression of GH, GHSR and IGF-1, and promoting the phosphorylation of Akt. This would provide promising insights into the treatment of hypoxic myocardial injury by ghrelin.