Misuse of prescription opioids is a well-established contributor to the US opioid epidemic. The primary objective of this study was to identify which level of care delivery (ie patient, prescriber, or hospital) produced the most unwarranted variation in opioid prescribing after common surgical procedures. Electronic health record data from a large multihospital healthcare system were used in conjunction with random-effect models to examine variation in opioid prescribing practices after similar inpatient and outpatient surgical procedures between October 2019 and September 2021. Unwarranted variation was conceptualized as variation resulting from prescriber behavior unsupported by evidence. Covariates identified as drivers of warranted variation included characteristics known to influence pain levels or patient safety. All other model variables, including prescriber specialty and patient race, ethnicity, and insurance status were characterized as potential drivers of unwarranted variation. Among 25,188 procedures with an opioid prescription at hospital discharge, 53.5% exceeded guideline recommendations, corresponding to 13,228 patients receiving the equivalent of >140,000 excess 5 mg oxycodone tablets after surgical procedures. Prescribing variation was primarily driven by prescriber-level factors, with approximately half of the total variation in morphine milligram equivalents prescribed observed at the prescriber level and not explained by any measured variables. Unwarranted covariates associated with higher prescribed opioid quantity included non-Hispanic Black race, Medicare insurance, smoking history, later hospital discharge times, and prescription by a surgeon rather than a hospitalist or primary care provider. Given the large proportion of unexplained variation observed at the provider level, targeting prescribers through education and training may be an effective strategy for reducing postoperative opioid prescribing.