Chronic pain is highly variable between individuals, as is the response to analgesics. Although much of the variability in chronic pain and analgesic response is heritable, an understanding of the genetic determinants underlying this variability is rudimentary. Here we show that variation within the coding sequence of the gene encoding the P2X7 receptor (P2X7R) affects chronic pain sensitivity in both mice and humans. P2X7Rs, which are members of the family of ionotropic ATP-gated receptors, have two distinct modes of function: they can function through their intrinsic cationic channel or by forming nonselective pores that are permeable to molecules with a mass of up to 900 Da. Using genome-wide linkage analyses, we discovered an association between nerve-injury-induced pain behavior (mechanical allodynia) and the P451L mutation of the mouse P2rx7 gene, such that mice in which P2X7Rs have impaired pore formation as a result of this mutation showed less allodynia than mice with the pore-forming P2rx7 allele. Administration of a peptide corresponding to the P2X7R C-terminal domain, which blocked pore formation but not cation channel activity, selectively reduced nerve injury and inflammatory allodynia only in mice with the pore-forming P2rx7 allele. Moreover, in two independent human chronic pain cohorts, a cohort with pain after mastectomy and a cohort with osteoarthritis, we observed a genetic association between lower pain intensity and the hypofunctional His270 (rs7958311) allele of P2RX7. Our findings suggest that selectively targeting P2X7R pore formation may be a new strategy for individualizing the treatment of chronic pain.