O-GlcNAcylation is a common posttranslational modification of nucleocytoplasmic proteins with beta-N-acetylglucosamine (GlcNAc) and regulates numerous biological processes. By using mouse models of cerebral ischemia induced by permanent and transient middle cerebral artery occlusion (MCAO), we observed an initial elevation (similar to 1.7-fold, 1-4 hours after ischemia) and then decline of O-GlcNAcylation during cerebral ischemia. We found that moderate increase (<3-fold) of brain O-GlcNAcylation by pharmacological means ameliorated cerebral ischemia-reperfusion injury and the consequent motor and neurological deficits. Interference of the transient elevation of O-GlcNAcylation pharmacologically or genetically aggravates the ischemia-induced brain damage, motor deficits and mortality. The alteration of O-GlcNAcylation was also seen in the ischemic areas of postmortem human brains. This study reveals an important regulation of cerebral ischemia-reperfusion injury by O-GlcNAcylation and also provides a possible therapeutic strategy, i.e., by increasing O-GlcNAcylation, to reduce the cerebral damage and improve the clinical outcome of ischemic stroke.