Cerebral ischemia/reperfusion (IR) after ischemic stroke causes deleterious microglial activation. Protein tyrosine phosphatase 1B (PTP1B) exacerbates neuroinflammation, yet the effect of the inhibition on microglial activation and cerebral IR injury is unknown. A cerebral IR rat model was induced by middle cerebral artery occlusion (MCAO) and reperfusion. The PTP1B inhibitor, sc-222227, was administered intracerebroventricularly. Neurologic deficits, infarct volume, and brain water content were examined. An in vitro oxygen glucose deprivation/reoxygenation (OGD/R) model was established in primary microglia and BV-2 cells. Microglial activation/polarization, endoplasmic reticulum (ER) stress, autophagy, and apoptosis were detected using western blot, immunohistology, ELISA, and real-time PCR. Protein interaction was assessed by a proximity ligation assay. The results showed a significant increase in microglial PTP1B expression after IR injury. Sc-222227 attenuated IR-induced microglial activation, ER stress, and autophagy and promoted M2 polarization. Upon OGD/R, sc-222227 mitigated microglial activation by inhibiting ER stress-dependent autophagy, the effect of which was abolished by PERK activation, and PERK inhibition attenuated microglial activation. The PTP1B-phosphorylated PERK protein interaction was significantly increased after OGD/R, but decreased upon sc-222227 treatment. Finally, sc-222227 mitigated neuronal damage and neurologic deficits after IR injury. Treatment targeting microglial PTP1B might be a potential therapeutic strategy for ischemic stroke treatment.