Gastric electrical stimulation (GES) has been applied to treat gastric motility disorders for decades. This study was designed to investigate the effects and mechanisms of GES for visceral hypersensitivity in a rodent model of functional dyspepsia (FD). Male Sprague-Dawley rat pups at 10-days old received 0.1% iodoacetamide (IA) daily for 6days. The experiments were performed when the rats reached 8-11weeks of age, and visceral hypersensitivity was established. Then, GES parameters were optimized and the chronic effects of GES on gastric hypersensitivity were assessed by electromyogram (EMG). Naloxone (3mg/kg), D-Phe-Cys-Tyr-D-Trp-Orn-Thr-Pen-Thr-NH2 (CTOP, 1mg/kg), and anti-NGF (16μg/kg) were individually intraperitoneally injected to investigate opioid and nerve growth factor (NGF) mechanisms. Tissues were analyzed for NGF expression. In the IA-treated rats, the visceromotor response to gastric distension was significantly increased, and both acute GES with optimized stimulation parameters (0.25seconds on, 0.25seconds off, 100Hz, 0.25ms, 6mA) and chronic GES (7days, 2 hours/day) normalized gastric hypersensitivity. The inhibitory effect of GES on gastric hypersensitivity was blocked by naloxone and CTOP. Anti-NGF normalized EMG responses in IA-treated rats. The expressions of NGF in the tissues of IA-treated rats were dramatically increased, and these increases were suppressed with GES. GES with optimized parameters improves gastric hypersensitivity induced by neonatal treatment of IA mediated peripherally by suppressing NGF and via the opioid mechanism involving the µ receptor. GES as a potential therapy for treating visceral pain may be explored in clinical studies.