SummaryBackgroundA considerable proportion of people who inject drugs are unstably housed. Although unstable housing is associated with HIV and HCV infection among people who inject drugs, its contribution to transmission is unknown. We estimated the global and national proportions of incident HIV and HCV infections among people who inject drugs attributed to housing instability from 2020 to 2029.MethodsIn this modelling study, we developed country-level models of unstable housing and HIV and HCV transmission among people who inject drugs in 58 countries globally, calibrated to country-specific data on the prevalences of HIV and HCV and unstable housing. Based on a recently published systematic review, unstably housed people who inject drugs were assumed to have a 39% (95% CI 6–84) increased risk of HIV transmission and a 64% (95% CI 43–89%) increased risk of HCV transmission. We used pooled country-level estimates from systematic reviews on HCV and HIV prevalence in people who inject drugs. Our models estimated the transmission population attributable fraction (tPAF) of unstable housing to HIV and HCV transmission among people who inject drugs, defined as the percentage of infections prevented from 2020 to 2029 if the additional risk due to unstable housing was removed.FindingsOur models were produced for 58 countries with sufficient data (accounting for >66% of the global people who inject drugs population). Globally, we project unstable housing contributes 7·9% (95% credibility interval [CrI] 2·3–15·7) of new HIV infections and 11·2% (7·7–15·5) of new HCV infections among people who inject drugs from 2020 to 2029. Country-level tPAFs were strongly associated with the prevalence of unstable housing. tPAFs were greater in high-income countries (HIV 17·2% [95% CrI 5·1–30·0]; HCV 19·4% [95% CrI 13·8–26·0]) than in low-income or middle-income countries (HIV 6·6% [95% CrI 1·8–13·1]; HCV 8·3% [95% CrI 5·5–11·7]). tPAFs for HIV and HCV were highest in Afghanistan, Czech Republic, India, USA, England, and Wales where unstable housing contributed more than 20% of new HIV and HCV infections.InterpretationUnstable housing is an important modifiable risk factor for HIV and HCV transmission among people who inject drugs in many countries. The study emphasises the importance of implementing initiatives to mitigate these risks and reduce housing instability.FundingNational Institute for Health Research and National Institute of Allergy and Infectious Diseases and National Institute for Drug Abuse.