The number of patients prescribed long-term opioids and benzodiazepines and complications from their long-term use have increased. Information regarding the perioperative outcomes of patients prescribed these medications before surgery is limited. To determine whether patients prescribed opioids and/or benzodiazepines within 6 months preoperatively would have greater short- and long-term mortality and increased opioid consumption postoperatively. This retrospective, single-center, population-based cohort study included all patients 18 years or older, undergoing noncardiac surgical procedures at a national hospital in Iceland from December 12, 2005, to December 31, 2015, with follow-up through May 20, 2016. A propensity score-matched control cohort was generated using individuals from the group that received prescriptions for neither medication class within 6 months preoperatively. Data analysis was performed from April 10, 2018, to March 9, 2019. Patients who filled prescriptions for opioids only, benzodiazepines only, both opioids and benzodiazepines, or neither medication within 6 months preoperatively. Long-term survival compared with propensity score-matched controls. Secondary outcomes were 30-day survival and persistent postoperative opioid consumption, defined as a prescription filled more than 3 months postoperatively. Among 41 170 noncardiac surgical cases in 27 787 individuals (16 004 women [57.6%]; mean [SD] age, 56.3 [18.8] years), a preoperative prescription for opioids only was filled for 7460 cases (17.7%), benzodiazepines only for 3121 (7.4%), and both for 2633 (6.2%). Patients who filled preoperative prescriptions for either medication class had a greater comorbidity burden compared with patients receiving neither medication class (Elixhauser comorbidity index >0 for 16% of patients filling prescriptions for opioids only, 22% for benzodiazepines only, and 21% for both medications compared with 14% for patients filling neither). There was no difference in 30-day (opioids only: 1.3% vs 1.0%; P = .23; benzodiazepines only: 1.9% vs 1.5%; P = .32) or long-term (opioids only: hazard ratio [HR], 1.12 [95% CI, 1.01-1.24]; P = .03; benzodiazepines only: HR, 1.11 [95% CI, 0.98-1.26]; P = .11) survival among the patients receiving opioids or benzodiazepines only compared with controls. However, patients prescribed both opioids and benzodiazepines had greater 30-day mortality (3.2% vs 1.8%; P = .004) and a greater hazard of long-term mortality (HR, 1.41; 95% CI, 1.22-1.64; P < .001). The rate of persistent postoperative opioid consumption was higher for patients filling prescriptions for opioids only (43%), benzodiazepines only (23%), or both (66%) compared with patients filling neither (12%) (P < .001 for all). The findings suggest that opioid and benzodiazepine prescription fills in the 6 months before surgery are associated with increased short-and long-term mortality and an increased rate of persistent postoperative opioid consumption. These patients should be considered for early referral to preoperative clinic and medication optimization to improve surgical outcomes.