To estimate the treated prevalence of mental illness, substance use disorder (SUD) and dual diagnosis and the association between dual diagnosis and fatal and non-fatal overdose among residents of British Columbia (BC), Canada. A retrospective cohort study using linked health, income assistance, corrections and death records. British Columbia (BC), Canada. A total of 921 346BC residents (455 549 males and 465 797 females) aged 10years and older. Hospital and primary-care administrative data were used to identify a history of mental illness only, SUD only, dual diagnosis or no history of SUD or mental illness (2010-14) and overdoses resulting in medical care (2015-17). We calculated crude incidence rates of non-fatal and fatal overdose by dual diagnosis history. Andersen-Gill and competing risks regression were used to examine the association between dual diagnosis and non-fatal and fatal overdose, respectively, adjusting for age, sex, comorbidities, incarceration history, social assistance, history of prescription opioid and benzodiazepine dispensing and region of residence. Of the 921 346 people in the cohort, 176 780 (19.2%), 6147 (0.7%) and 15 269 (1.7%) had a history of mental illness only, SUD only and dual diagnosis, respectively; 4696 (0.5%) people experienced 688 fatal and 6938 non-fatal overdoses. In multivariable analyses, mental illness only, SUD only and dual diagnosis were associated with increased rate of non-fatal [hazard ratio (HR)=1.8, 95% confidence interval (CI)=1.6-2.1; HR=9.0, 95% CI=7.0-11.5, HR=8.7, 95% CI=6.9-10.9, respectively] and fatal overdose (HR = 1.6, 95% CI=1.3-2.0, HR=4.3, 95% CI=2.8-6.5, HR=4.1, 95% CI=2.8-6.0, respectively) compared with no history. In a large sample of residents of British Columbia (Canada), approximately one in five people had sought care for a substance use disorder or mental illness in the past 5years. The rate of overdose was elevated in people with a mental illness alone, higher again in people with a substance use disorder alone and highest in people with a dual diagnosis. The adjusted hazard rates were similar for people with substance use disorder only and people with a dual diagnosis.