Thymoquinone is one of the main components present in Nigella sativa seeds and is known to have various biological functions in inflammation, oxidative stress, tumors, aging, and in lowering blood glucose levels. Few studies have focused on its neuroprotective effects and its regulation of small-molecule metabolites during cerebral ischemia reperfusion injury. In this study, transient middle cerebral occlusion (tMCAO) was used to establish the rat model of cerebral ischemia reperfusion injury. We investigated the effects of thymoquinone using matrix-assisted laser desorption ionization mass spectrometry imaging (MALDI-MSI) in a model of ischemia reperfusion injury to explore the changes in small-molecule metabolites in the brain. We found that that thymoquinone significantly improved neurobehavioral scores, reduced the cerebral infarct area, alleviated brain edema, and increased the number of normal neurons following injury. MALDI-MSI revealed that thymoquinone reduced abnormal accumulations of glucose, citric acid, succinate and potassium ions. Thymoquinone also increased the amount of energy-related molecules such as ADP, AMP, GMP, and creatine, antioxidants such as glutathione, ascorbic acid, and taurine, and other metabolism-related molecules such as glutamate, glutamine, aspartate, N-acetyl-L-aspartate, and sodium ions in damaged areas of the brain following cerebral ischemia reperfusion injury. In summary, based on the neuroprotective effect of thymoquinone on cerebral ischemia reperfusion injury, this study revealed the regulation of thymoquinone on energy metabolism and small-molecule substance metabolism.