Objectives: To examine survival and long term cessation of injecting in a cohort of drug users and to assess the influence of opiate substitution treatment on these outcomes. Design: Prospective open cohort study. Setting: A single primary care facility in Edinburgh. Participants 794 patients with a history of injecting drug use presenting between 1980 and 2007; 655 (82%) were followed up by interview or linkage to primary care records and mortality register, or both, and contributed 10 390 person years at risk; 557 (85%) had received opiate substitution treatment. Main outcome measures: Duration of injecting: years from first injection to long term cessation, defined as last injection before period of five years of non-injecting; mortality before cessation; overall survival. Results: In the entire cohort 277 participants achieved long term cessation of injecting, and 228 died. Half of the survivors had poor health related quality of life. Median duration from first injection to death was 24 years for participants with HIV and 41 years for those without HIV. For each additional year of opiate substitution treatment the hazard of death before long term cessation fell 13% (95% confidence interval 17% to 9%) after adjustment for HIV, sex, calendar period, age at first injection, and history of prison and overdose. Conversely exposure to opiate substitution treatment was inversely related to the chances of achieving long term cessation. Conclusions: Opiate substitution treatment in injecting drug users in primary care reduces this risk of mortality, with survival benefits increasing with cumulative exposure to treatment. Treatment does not reduce the overall duration of injecting.