Background and AimsPeople who inject drugs (PWID) experience high incarceration rates, and previous incarceration is associated with elevated hepatitis C virus (HCV) transmission risk. In Scotland, national survey data indicate lower HCV incidence in prison than the community (4.3 versus 7.3 per 100 person‐years), but a 2.3‐fold elevated transmission risk among recently released (< 6 months) PWID. We evaluated the contribution of incarceration to HCV transmission among PWID and the impact of prison‐related prevention interventions, including scaling‐up direct‐acting antivirals (DAAs) in prison.DesignDynamic mathematical modelling of incarceration and HCV transmission, using approximate Bayesian computation for model calibration.SettingScotland, UK.ParticipantsA simulated population of PWID.MeasurementsPopulation‐attributable fraction (PAF) of incarceration to HCV transmission among PWID. Decrease in HCV incidence and chronic prevalence due to current levels of prison opiate substitution therapy (OST; 57% coverage) and HCV treatment, as well as scaling‐up DAAs in prison and/or preventing the elevated risk associated with prison release.FindingsIncarceration contributes 27.7% [PAF; 95% credible interval (CrI) –3.1 to 51.1%] of HCV transmission among PWID in Scotland. During the next 15 years, current HCV treatment rates (10.4/6.8 per 1000 incarcerated/community PWID annually), with existing prison OST, could reduce incidence and chronic prevalence among all PWID by a relative 10.7% (95% CrI = 8.4–13.3%) and 9.7% (95% CrI = 7.7–12.1%), respectively. Conversely, without prison OST, HCV incidence and chronic prevalence would decrease by 3.1% (95% CrI = –28.5 to 18.0%) and 4.7% (95% CrI = –11.3 to 14.5%). Additionally, preventing the heightened risk among recently released PWID could reduce incidence and chronic prevalence by 45.0% (95% CrI = 19.7–57.5%) and 33.3% (95% CrI = 15.6–43.6%) or scaling‐up prison HCV treatments to 80% of chronic PWID prison entrants with sufficient sentences (>16 weeks) could reduce incidence and prevalence by 45.6% (95% CrI = 38.0–51.3%) and 45.5% (95% CrI = 39.3–51.0%), respectively.ConclusionsIncarceration and the elevated transmission risk following prison release can contribute significantly to hepatitis C virus transmission among people who inject drugs. Scaling‐up hepatitis C virus treatment in prison can provide important prevention benefits.