Cerebral ischemia-reperfusion injury (CIRI) is a significant pathological process in stroke, characterized by neuronal cell death and neurological dysfunction. Metformin, commonly used for diabetes management, has been noted for its neuroprotective properties, though its effects on CIRI and the mechanisms involved remain unclear. This study explored the neuroprotective impact of metformin on CIRI, focusing on its potential to modulate the c-Jun N-terminal kinase (JNK) and p38 MAP kinase (p38) signaling pathways. Using in vitro models of oxygen-glucose deprivation/reperfusion (OGD/R) in neuronal cells and in vivo mouse models of middle cerebral artery occlusion (MCAO), the effects of metformin were assessed. Cell viability was measured with Cell Counting Kit-8 (CCK-8), protein expression via Western Blot (WB), and apoptosis through flow cytometry. The extent of brain injury in mice was evaluated using 2,3,5-triphenyltetrazolium chloride (TTC) staining, while JNK and p38 activation statuses were detected through WB and phospho-JNK (p-JNK) immunofluorescence staining. Results showed that metformin significantly improved the viability of HT22 cells post-OGD/R, reduced apoptosis, and decreased OGD/R-induced phosphorylation of JNK and p38 in vitro. In vivo, metformin treatment notably reduced brain infarct volume in MCAO mice, inhibited p-p38 and p-JNK expression, and enhanced neurological function. These findings suggest that metformin exerts neuroprotective effects against CIRI by modulating the JNK/p38 signaling pathway, highlighting its potential therapeutic value in treating cerebral ischemia-reperfusion injury and paving the way for clinical applications.