This study explored the role of P2X7 receptors in spinal cord astrocytes in the electroacupuncture-induced inhibition of visceral hypersensitivity (VH) in rats with irritable bowel syndrome (IBS). Visceral hypersensitivity of IBS was intracolonically induced by 2,4,6-trinitrobenzene sulfonic acid (TNBS). Visceromotor responses to colorectal distension (CRD-20,40,60,80 mmHg) and abdominal withdrawal reflex scoring (AWRs) were recorded after electroacupuncture at bilateral Zusanli (ST36) and Sanyinjiao (SP6) acupoints to evaluate the analgesic effect of electroacupuncture on visceral pain in rats with IBS. Fluorocitric acid (FCA), an astrocyte activity inhibitor, was injected intrathecally before electroacupuncture intervention and AWRs were recorded. Western blot and real-time qPCR were used to detect the expression of NMDA and P2X7 receptor to observe the regulation effect of electroacupuncture on NMDA receptor in the spinal cord of rats with visceral hypersensitivity. Intrathecal injection of P2X7 agonist or antagonist was administered before electroacupuncture treatment. To observe the effect of P2X7 receptor in spinal astrocytes on the inhibition of visceral hyperalgesia by electroacupuncture, the changes of AWR score, NMDA receptor in the spinal cord, and GFAP expression in astrocytes were detected. Inflammation of the colon had basically subsided at day 21 post-TNBS; persistent visceral hypersensitivity could be suppressed by electroacupuncture. This analgesic effect could be inhibited by FCA. The analgesic effect, downregulation of NMDA receptor NR1 subunit, and P2X7 protein of electroacupuncture were all reversed by FCA. P2X7 receptor antagonist A740003 can cooperate with EA to carry out analgesic effect in rats with visceral pain and downregulate the expression of NR1, NR2B, and GFAP in spinal dorsal horn. However, the P2X7 receptor agonist BzATP could partially reverse the analgesic effect of EA, inhibiting the downregulatory effect of EA on the expression of NR1, NR2B, and GFAP. These results indicate that EA may downregulate the expression of the NMDA receptor by inhibiting the P2X7 receptor in the spinal cord, thereby inhibiting spinal cord sensitization in IBS rats with visceral pain, in which astrocytes are an important medium.