Spinal cord injury (SCI) is a devastating neurological disorder, but few drugs have proven to be effective for its treatment. Neuroinflammation exaggerates the secondary injury subsequent to trauma. Emerging evidence suggests that melatonin may help protect neural tissue against secondary injury after SCI, but the underlying mechanisms remain elusive. Microglial/macrophages polarization plays an important role in regulating immune responses. To examine whether melatonin exerts neuroprotective effects after acute SCI by regulating microglial/macrophages polarization in the spinal cord, we administered intraperitoneal injections of melatonin (50 mg/kg) in female rats immediately after SCI and then daily for seven consecutive days (n = 6). Compared with the vehicle‐treated group (n = 6), the melatonin‐treated group exhibited a greater Basso, Beattie, and Bresnahan locomotor rating score, smaller spinal cavity, and less cleaved caspase 3 immunofluorescence staining in the injured spinal segments. Real‐time PCR data revealed decreases in the expression levels of M1 microglia phenotypic markers and increases in M2 markers in the spinal cord of melatonin‐treated SCI rats, as compared to levels in the vehicle‐treated group. Melatonin increased the number of CD206+ and Arg1+ cells, decreased the number of CD16+ and iNOS+ cells and reduced the levels of pro‐inflammatory cytokines (TNF‐α, IL‐6, and IL‐1β) in the spinal cord tissue of female SCI rats. Current findings suggest that melatonin may inhibit pro‐inflammatory responses and promote M2 polarization of microglial/macrophages in the spinal cord in the early stage of SCI, facilitating functional recovery. Accordingly, melatonin may represent a promising therapeutic candidate for acute SCI.