Opioids are very effective analgesics, but they are also highly addictive. Methadone is used to treat opioid dependence (OD), acting as a selective agonist at the μ-opioid receptor encoded by the gene OPRM1. Determining the optimal methadone maintenance dose is time consuming; currently, no biomarkers are available to guide treatment. In methadone-treated OD subjects drawn from a case and control sample, we conducted a genome-wide association study of usual daily methadone dose. In African-American (AA) OD subjects (n=383), we identified a genome-wide significant association between therapeutic methadone dose (mean=68.0 mg, s.d.=30.1 mg) and rs73568641 (P=2.8 × 10-8), the nearest gene (306 kilobases) being OPRM1. Each minor (C) allele corresponded to an additional ~20 mg day-1 of oral methadone, an effect specific to AAs. In European-Americans (EAs) (n=1027), no genome-wide significant associations with methadone dose (mean=77.8 mg, s.d.=33.9 mg) were observed. In an independent set of opioid-naive AA children being treated for surgical pain, rs73568641-C was associated with a higher required dose of morphine (n=241, P=3.9 × 10-2). Similarly, independent genomic loci previously shown to associate with higher opioid analgesic dose were associated with higher methadone dose in the OD sample (AA and EA: n=1410, genetic score P=1.3 × 10-3). The present results in AAs indicate that genetic variants influencing opioid sensitivity across different clinical settings could contribute to precision pharmacotherapy for pain and addiction.