© 2018 Wolters Kluwer Health, Inc. All rights reserved. Background: Chronic pain occurs in up to 85% of persons living with HIV and is commonly treated with long-term opioid therapy (LTOT). We investigated the impact of chronic pain and LTOT on HIV outcomes. Methods: This was prospective cohort study conducted between July 2015 and July 2016 in 5 HIV primary care clinics. Chronic pain was defined as ≥moderate pain for ≥3 months on the Brief Chronic Pain Questionnaire. Chronic pain and LTOT were assessed at an index visit. Suboptimal retention, defined as at least one "no-show" to primary care, and virologic failure were measured over the subsequent year. Multivariable logistic regression models were built for each outcome adjusting for site. Results: Among 2334 participants, 25% had chronic pain, 27% had suboptimal retention, 12% had virologic failure, and 19% were prescribed LTOT. Among individuals not on LTOT, chronic pain was associated with increased odds of suboptimal retention [adjusted odds ratio (aOR) 1.46, 95% confidence interval (CI): 1.10 to 1.93, P = 0.009] and virologic failure (aOR 1.97, 95% CI: 1.39 to 2.80, P < 0.001). Among individuals with chronic pain, there was no association between LTOT and retention, but LTOT was associated with lower rates of virologic failure (aOR 0.56, 95% CI: 0.33 to 0.96, P = 0.03). Conclusions: Chronic pain in participants not on LTOT was associated with virologic failure. This reinforces the need to identify effective chronic pain treatments for persons living with HIV and investigate their impact on HIV outcomes. The apparent protective association between LTOT and virologic failure in those with pain merits further exploration.