Postoperative cognitive dysfunction (POCD) is a significant cause of morbidity after surgery, especially for the elderly. Accumulating evidence has demonstrated that neuroinflammation plays a key role in the pathogenesis of POCD. Thus, we hypothesized that berberine, an isoquinoline alkaloid with anti-inflammatory effects, could improve surgery-induced cognitive impairment. Twenty-month-old male C57BL/6 mice were subjected to exploratory laparotomy with isoflurane anesthesia to mimic the clinical human abdominal surgery. For the interventional studies, mice received berberine (10 mg/kg) or vehicle intraperitoneally. For the in vitro study, we examined the effects of berberine on lipopolysaccharide (LPS)-induced inflammatory mediators by cultured BV2 cells. Behavioral tests, expressions of IBA1, tumor necrosis factor-α (TNF-α), interleukin-1β (IL-1β), and IL-6 were performed at the indicated time points. In the present study, we showed that surgery impaired the contextual fear memory, as evidenced by the significantly decreased freezing time to the context. This behavioral change coincided with marked increases in IBA1, TNF-α, IL-1β, and IL-6 in the prefrontal cortex and hippocampus only at 24 h but not 7 d after surgery. In BV2 cells, LPS induced significantly increased TNF-α and IL-1β expressions. Notably, berberine treatment rescued surgery-induced cognitive impairment and inhibited the release of IBA1, IL-1β, and IL-6 in the hippocampus. In line with the in vivo study, berberine treatment suppressed LPS-stimulated production of TNF-α and IL-1β in BV2 cells. In conclusion, our study suggests that berberine could alleviate POCD by suppressing neuroinflammation in aged mice.