Bacterial products can act on neurons to alter signaling and function. In the present study, we found that dorsal root ganglion (DRG) sensory neurons are enriched for ANTXR2, the high-affinity receptor for anthrax toxins. Anthrax toxins are composed of protective antigen (PA), which binds to ANTXR2, and the protein cargoes edema factor (EF) and lethal factor (LF). Intrathecal administration of edema toxin (ET (PA + EF)) targeted DRG neurons and induced analgesia in mice. ET inhibited mechanical and thermal sensation, and pain caused by formalin, carrageenan or nerve injury. Analgesia depended on ANTXR2 expressed by Na1.8 or Advillin neurons. ET modulated protein kinase A signaling in mouse sensory and human induced pluripotent stem cell-derived sensory neurons, and attenuated spinal cord neurotransmission. We further engineered anthrax toxins to introduce exogenous protein cargoes, including botulinum toxin, into DRG neurons to silence pain. Our study highlights interactions between a bacterial toxin and nociceptors, which may lead to the development of new pain therapeutics.