Accumulating observations suggest that peripheral somatosensory ganglia may regulate pain transmission, yet direct evidence is sparse. Here we show that the peripheral afferent nociceptive information undergoes dynamic filtering within dorsal root ganglia (DRG) and suggest that this filtering occurs at the axonal bifurcations (t-junctions). Using simultaneous in vivo electrophysiological recordings from the peripheral (spinal nerve) and central (dorsal root) aspects of rodent spinal nerves, ganglionic transplantation of GABAergic progenitor cells, and optogenetics we demonstrate tonic and dynamic filtering of action potentials traveling through the DRG. Filtering induced by focal application of GABA or optogenetic GABA release from the DRG-transplanted GABAergic progenitor cells was specific to nociceptive fibers. Light-sheet imaging and computer modeling demonstrated that, compared to other somatosensory fiber types, nociceptors have shorter stem axons, making somatic control over t-junctional filtering more efficient. Optogenetically-induced GABA release within DRG enhanced filtering and reduced both acute and chronic inflammatory and neuropathic pain in vivo. These findings support the potential gating of pain information within the somatosensory system, and suggests new therapeutic approaches for pain relief.