Background Chronic pain is prevalent among people living with human immunodeficiency virus (PLWH); managing pain with chronic opioid therapy (COT) is common. Human immunodeficiency virus (HIV) providers often diverge from prescribing guidelines. Methods This 2-arm, unblinded, cluster-randomized clinical trial assessed whether the Targeting Effective Analgesia in Clinics for HIV (TEACH) intervention improves guideline-concordant care compared to usual care for PLWH on COT. The trial was implemented from 2015 to 2018 with 12-month follow-up at safety-net hospital–based HIV clinics in Boston and Atlanta. We enrolled 41 providers and their 187 patients on COT. Prescribers were randomized 1:1 to either a 12-month intervention consisting of a nurse care manager with an interactive electronic registry, opioid education, academic detailing, and access to addiction specialists or a control condition consisting of usual care. Two primary outcomes were assessed through electronic medical records: ≥2 urine drug tests and any early COT refills by 12 months. Other outcomes included possible adverse consequences. Results At 12 months, the TEACH intervention arm had higher odds of ≥2 urine drug tests than the usual care arm (71% vs 20%; adjusted odds ratio [AOR], 13.38 [95% confidence interval {CI}, 5.85–30.60]; P <.0001). We did not detect a statistically significant difference in early refills (22% vs 30%; AOR, 0.55 [95% CI,.26–1.15]; P =.11), pain severity (6.30 vs 5.76; adjusted mean difference, 0.10 [95% CI, −1.56 to 1.75]; P =.91), or HIV viral load suppression (86.9% vs 82.1%; AOR, 1.21 [95% CI,.47–3.09]; P =.69). Conclusions TEACH is a promising intervention to improve adherence to COT guidelines without evident adverse consequences. [ABSTRACT FROM AUTHOR]