Acute ischemic stroke followed by microglia activation, and the regulation of neuroinflammatory responses after ischemic injury involves microglia polarization. microglia polarization is involved in the regulation of neuroinflammatory responses and ischemic stroke-related brain damage. Thymoquinone (TQ) is an anti-inflammatory agent following ischemic stroke onset. However, the significance of TQ in microglia polarization following acute ischemic stroke is still unclear. We predicted that TQ might have neuroprotective properties by modulating microglia polarization. In this work, we mimicked the clinical signs of acute ischemic stroke using a mouse middle cerebral artery ischemia-reperfusion (I/R) model. It was discovered that TQ treatment decreased I/R-induced infarct volume, cerebral oedema, and promoted neuronal survival, as well as improved the histopathological changes of brain tissue. The sensorimotor function was assessed by the Garica score, foot fault test, and corner test, and it was found that TQ could improve the motor deficits caused by I/R. Secondly, real-time fluorescence quantitative PCR, immuno-fluorescence, ELISA, and western blot were used to detect the expression of M1/M2-specific markers in microglia to explore the role of TQ in the modulation of microglial cell polarization after cerebral ischemia-reperfusion. We found that TQ was able to promote the polarization of microglia with extremely secreted inflammatory factors from M1 type to M2 type. Furthermore, TQ could block the TLR4/NF-κB signaling pathway via Hif-1α activation which subsequently may attenuate microglia differentiation following the cerebral ischemia, establishing a mechanism for the TQ's beneficial effects in the cerebral ischemia-reperfusion model.