BACKGROUND:Ecological research suggests that increased access to cannabis may facilitate reductions in opioid use and harms, and medical cannabis patients describe the substitution of opioids with cannabis for pain management. However, there is a lack of research using individual-level data to explore this question. We aimed to investigate the longitudinal association between frequency of cannabis use and illicit opioid use among people who use drugs (PWUD) experiencing chronic pain. METHODS AND FINDINGS:This study included data from people in 2 prospective cohorts of PWUD in Vancouver, Canada, who reported major or persistent pain from June 1, 2014, to December 1, 2017 (n = 1,152). We used descriptive statistics to examine reasons for cannabis use and a multivariable generalized linear mixed-effects model to estimate the relationship between daily (once or more per day) cannabis use and daily illicit opioid use. There were 424 (36.8%) women in the study, and the median age at baseline was 49.3 years (IQR 42.3-54.9). In total, 455 (40%) reported daily illicit opioid use, and 410 (36%) reported daily cannabis use during at least one 6-month follow-up period. The most commonly reported therapeutic reasons for cannabis use were pain (36%), sleep (35%), stress (31%), and nausea (30%). After adjusting for demographic characteristics, substance use, and health-related factors, daily cannabis use was associated with significantly lower odds of daily illicit opioid use (adjusted odds ratio 0.50, 95% CI 0.34-0.74, p < 0.001). Limitations of the study included self-reported measures of substance use and chronic pain, and a lack of data for cannabis preparations, dosages, and modes of administration. CONCLUSIONS:We observed an independent negative association between frequent cannabis use and frequent illicit opioid use among PWUD with chronic pain. These findings provide longitudinal observational evidence that cannabis may serve as an adjunct to or substitute for illicit opioid use among PWUD with chronic pain.