Cucurbitacin B, a tetracyclic triterpenoid compound extracted from various plants, has been proven to exert a vital role in various diseases. However, the effect of cucurbitacin B on myocardial infarction (MI) and ischemia-reperfusion (I/R) injury is still relatively unclear. The main purpose of the present study was to investigate the effect of cucurbitacin B on cell apoptosis and oxidative damage after myocardial I/R injury in vitro and in vivo and elucidate the molecular mechanisms underlying its role. The 56-day-old adult mice and 1-day-old neonatal mice cardiomyocytes were used to construct I/R or oxygen-glucose deprivation/reoxygenation (OGD/R) injury models. The oxidative injury, western blot and TUNEL assay were performed to evaluate cardiomyocyte damage in the present study. In vitro, we confirmed that cucurbitacin B could attenuate LDH release, oxidative stress and cell apoptosis in cardiomyocytes exposed to OGD/R. Besides, we confirmed in an adult I/R mouse model that cucurbitacin B can improve cardiac repair and block cell apoptosis in the acute phase (24 h) post-myocardial I/R injury, as well as promote long-term cardiac function and fiber scar area after 28 days of I/R. Mechanically, we clarify that cucurbitacin B exerts cardiomyocyte protective effects through activating the JAK2/STAT3 signaling pathway. In conclusion, our study elucidates for the first time the protective role of cucurbitacin B in cardiac I/R injury, which provides a novel perspective for better prevention of I/R injury through the JAK2/STAT3 signaling pathway.