Microglial activation and melatonin protection have been reported in diabetic retinopathy (DR). Whether melatonin could regulate microglia to protect the inner blood–retinal barrier (iBRB) remains unknown. In this study, the role of microglia in iBRB breakdown and the mechanisms of melatonin’s regulation on microglia were explored. In diabetic rat retinas, activated microglia proliferated and migrated from the inner retina to the outer retina, accompanied by the obvious morphological changes. Meanwhile, significant leakage of albumin was evidenced at the site of close interaction between activated microglia and the damaged pericytes and endothelial cells. In vitro, inflammation-related cytokines, such as tumor necrosis factor-α (TNF-α), inducible nitric oxide synthase (iNOS), interleukin (IL)-1β, and arginase-1 (Arg-1), were increased significantly in CoCl2-treated BV2 cells. The supernatant derived from CoCl2-treated BV2 cells significantly decreased the cell viability and disrupted the junctional proteins in both pericytes and endothelial cells, resulting in severe leakage. Melatonin suppressed the microglial overactivation, i.e., decreasing the cell number and promoting its anti-inflammatory properties in diabetic rat retinas. Moreover, the leakage of iBRB was alleviated and the pericyte coverage was restored after melatonin treatment. In vitro, when treated with melatonin in CoCl2-treated BV2 cells, the inflammatory factors were decreased, while the anti-inflammatory factors were increased, further reducing the pericyte loss and increasing the tight junctions. Melatonin deactivated microglia via inhibition of PI3K/Akt/Stat3/NF-κB signaling pathways, thus maintaining the integrity of iBRB. The present data support a causal role for activated microglia in iBRB breakdown and highlight the therapeutic potential of melatonin in the treatment of DR by regulating microglia.