Chronic pain is a common problem, with more than one-fifth of adult Americans reporting pain daily or on most days. It adversely affects quality of life and imposes substantial personal and economic costs. Efforts to treat chronic pain using opioids played a central role in precipitating the opioid crisis. Despite an estimated heritability of 25–50%, the genetic architecture of chronic pain is not well characterized, in part because studies have largely been limited to samples of European ancestry. To help address this knowledge gap, we conducted a cross-ancestry meta-analysis of pain intensity in 598,339 participants in the Million Veteran Program, which identified 125 independent genetic loci, 82 of which are novel. Pain intensity was genetically correlated with other pain phenotypes, level of substance use and substance use disorders, other psychiatric traits, education level, and cognitive traits. Integration of the GWAS findings with functional genomics data shows enrichment for putatively causal genes (n = 142) and proteins (n = 14) expressed in brain tissues, specifically in GABAergic neurons. Drug repurposing analysis identified anticonvulsants, beta-blockers, and calcium-channel blockers, among other drug groups, as having potential analgesic effects. Our results provide insights into key molecular contributors to the experience of pain and highlight attractive drug targets.