Tools that are directly integrated with the electronic health record (EHR) workflow can reduce the hassle cost of certain guideline-concordant practices, such as querying a prescription drug monitoring program (PDMP) before prescribing opioids. To investigate the effect of integrating access to a PDMP within the EHR on the frequency of program queries by primary care clinicians. The PRINCE (Prescribing Interventions for Chronic Pain Using the Electronic Health Record) randomized trial used a factorial cluster design at the clinic level in 43 primary care clinics in Minnesota. In all, 309 clinicians participated; 161 clinicians were given EHR-integrated access to PDMP at the intervention clinics, and 148 clinicians had the usual access at the control clinics. The intervention went live on August 27, 2020, and data were collected through March 3, 2021. Single sign-on access to the Minnesota PDMP was integrated into the EHR, allowing clinicians to query a patient's controlled substance prescription and dispensing history as recorded in the Minnesota PDMP directly from the patient's EHR record without logging into a separate web portal. Additionally, the integration tool alerted clinicians and reminded them to review the PDMP if a patient had 3 or more opioid prescriptions in the past year and 1 or more in the past 6 months. Clinics in the control group did not receive access to the EHR-integrated PDMP tool; instead, these participants logged into the PDMP web portal separately. Monthly PDMP query counts for primary care clinicians, overall and by modality (EHR-based, web-based, via a clinical delegate), adjusted for clinician characteristics, including type (physician, nurse practitioner, physician assistant), sex, and years in practice. Data were analyzed from August 2021 to May 2022. Of the 43 participating clinics with 309 clinicians, 21 clinics with 161 clinicians (102 [63.4%] women; 114 [70.8%] physicians; tenure, 10.6 [4.4] years) received the PDMP integration intervention. Baseline unadjusted monthly PDMP query rates for the average clinician were 6.6 (95% CI, 4.4-9.9) vs 8.8 (95% CI, 6.0-13.1) queries in the control vs the PDMP integration group, respectively. During the intervention, PDMP query rates for the average clinician were 6.9 (95% CI, 4.7-10.3) vs 14.8 (95% CI, 10.0-22.0) queries among the control vs the PDMP integration group, respectively. Compared with the control group, the EHR-integrated PDMP tool produced a 60% greater increase in the relative change in monthly PDMP queries (95% CI, 51%-70%). An increase in PDMP queries via the EHR-integrated PDMP tool drove this increase, while web-based and delegate queries declined by 39% more among the intervention compared with the control group (95% CI, 34%-43%). This cluster randomized clinical trial found that integrating access to the PDMP in the EHR increased PDMP-querying rates, suggesting that direct access reduced hassle costs and can dramatically improve adherence to guideline-concordant care practices among primary care clinicians. ClinicalTrials.gov Identifier: NCT04601506.