We evaluated the effectiveness of ledipasvir/sofosbuvir (LDV/SOF) in treating hepatitis C virus (HCV) genotype 1 and SOF/velpatasvir (SOF/VEL) for all genotypes among people who inject drugs (PWID) and those not injecting drugs and who were on or off opioid agonist therapy (OAT). Study participants comprised a population‐based cohort in British Columbia, Canada. The British Columbia Hepatitis Testers Cohort includes data on individuals tested for HCV from 1990 to 2016 that are integrated with medical visits, hospitalization, and prescription drug data. We classified study participants as off OAT/recent injection drug use (off‐OAT/RIDU), off OAT/past IDU (off‐OAT/PIDU), off OAT/no IDU (off‐OAT/NIDU), on OAT/IDU (on‐OAT/IDU), and on OAT/no IDU (on‐OAT/NIDU). We assessed sustained virologic response (SVR) 10 weeks after HCV treatment among study groups treated with LDV/SOF or SOF/VEL until January 13, 2018. Analysis included 5,283 eligible participants: 390 off‐OAT/RIDU, 598 off‐OAT/PIDU, 3,515 off‐OAT/NIDU, 609 on‐OAT/IDU, and 171 on‐OAT/NIDU. The majority were male patients (64%‐74%) and aged ≥50 years (58%‐85%). The SVRs for off‐OAT/RIDU, off‐OAT/PIDU, off‐OAT/NIDU, on‐OAT/IDU, and on‐OAT/NIDU were 91% (355/390), 95% (570/598), 96% (3,360/3,515), 93% (567/609), and 95% (163/171), respectively. Among those with no SVR, 14 individuals died while on treatment or before SVR assessment, including 4 from illicit drug overdose. In the overall multivariable model, off‐OAT/RIDU, on‐OAT/IDU, male sex, cirrhosis, treatment duration <8 weeks, treatment duration 8 weeks, and treatment with SOF/VEL were associated with not achieving SVR. Conclusion: In this large real‐world cohort, PWID and/or those on OAT achieved high SVRs, although slightly lower than people not injecting drugs. This finding also highlights the need for additional measures to prevent loss to follow‐up and overdose‐related deaths among PWID.