IMPORTANCE: Prescription opioid misuse is a national crisis. Few interventions have improved adherence to opioid-prescribing guidelines. OBJECTIVE: To determine whether a multicomponent intervention, Transforming Opioid Prescribing in Primary Care (TOPCARE; http://mytopcare.org/), improves guideline adherence while decreasing opioid misuse risk. DESIGN, SETTING, AND PARTICIPANTS: Cluster-randomized clinical trial among 53 primary care clinicians (PCCs) and their 985 patients receiving long-term opioid therapy for pain. The study was conducted from January 2014 to March 2016 in 4 safety-net primary care practices. INTERVENTIONS: Intervention PCCs received nurse care management, an electronic registry, 1-on-1 academic detailing, and electronic decision tools for safe opioid prescribing. Control PCCs received electronic decision tools only. MAIN OUTCOMES AND MEASURES: Primary outcomes included documentation of guideline-concordant care (both a patient-PCC agreement in the electronic health record and at least 1 urine drug test [UDT]) over 12 months and 2 or more early opioid refills. Secondary outcomes included opioid dose reduction (ie, 10% decrease in morphine-equivalent daily dose [MEDD] at trial end) and opioid treatment discontinuation. Adjusted outcomes controlled for differing baseline patient characteristics: substance use diagnosis, mental health diagnoses, and language. RESULTS: Of the 985 participating patients, 519 were men, and 466 were women (mean [SD] patient age, 54.7 [11.5] years). Patients received a mean (SD) MEDD of 57.8 (78.5) mg. At 1 year, intervention patients were more likely than controls to receive guideline-concordant care (65.9% vs 37.8%; P < .001; adjusted odds ratio [AOR], 6.0; 95% CI, 3.6-10.2), to have a patient-PCC agreement (of the 376 without an agreement at baseline, 53.8% vs 6.0%; P < .001; AOR, 11.9; 95% CI, 4.4-32.2), and to undergo at least 1 UDT (74.6% vs 57.9%; P < .001; AOR, 3.0; 95% CI, 1.8-5.0). There was no difference in odds of early refill receipt between groups (20.7% vs 20.1%; AOR, 1.1; 95% CI, 0.7-1.8). Intervention patients were more likely than controls to have either a 10% dose reduction or opioid treatment discontinuation (AOR, 1.6; 95% CI, 1.3-2.1; P < .001). In adjusted analyses, intervention patients had a mean (SE) MEDD 6.8 (1.6) mg lower than controls (P < .001). CONCLUSIONS AND RELEVANCE: A multicomponent intervention improved guideline-concordant care but did not decrease early opioid refills. TRIAL REGISTRATION: clinicaltrials.gov Identifier: NCT01909076.