Microglia–neuron signalling in the spinal cord is a key mediator of mechanical allodynia caused by peripheral nerve injury. We recently reported sex differences in microglia in pain signalling in mice: spinal mechanisms underlying nerve injury–induced allodynia are microglial dependent in male but not female mice. Whether this sex difference in pain hypersensitivity mechanisms is conserved in other species is unknown. Here, we show that in rats, the spinal mechanisms of nerve injury–induced hypersensitivity in males differ from those in females, with microglial P2X4 receptors (P2X4Rs) being a key point of divergence. In rats, nerve injury produced comparable allodynia and reactive microgliosis in both sexes. However, inhibiting microglia in the spinal cord reversed allodynia in male rats but not female rats. In addition, pharmacological blockade of P2X4Rs, by an intrathecally administered antagonist, attenuated pain hypersensitivity in male rats only. Consistent with the behavioural findings, nerve injury increased cell surface expression and function of P2X4Rs in acutely isolated spinal microglia from male rats but not from female rats. Moreover, in microglia cultured from male rats, but not in those from female rats, stimulating P2X4Rs drove intracellular signalling through p38 mitogen-activated protein kinase. Furthermore, chromatin immunoprecipitation–qPCR revealed that the transcription factor IRF5 differentially binds to the P2rx4 promoter region in female rats vs male rats. Finally, mechanical allodynia was produced in otherwise naive rats by intrathecally administering P2X4R-stimulated microglia from male rats but not those from female rats. Together, our findings demonstrate the existence of sexually dimorphic pain signalling in rats, suggesting that this sex difference is evolutionarily conserved, at least across rodent species.