Prisoners experience very high rates of drug dependence, health problems and premature mortality. Without intervention they are highly likely to come into further contact with the criminal justice system, creating further health risk. Opioid dependence is a common problem among prisoners, and opioid substitution therapy (OST - methadone and buprenorphine) for opioid dependence may be an effective intervention in preventing morbidity, mortality and offending. Using retrospective data linkage, this study evaluated engagement with treatment, patterns of offending, incarceration and mortality among opioid-dependent people who received OST in New South Wales, Australia, at some time between 1985-2010. OST records were linked with data on all court appearances 1993-2011, custody episodes 2000-2012, and mortality 1985-2012. Our findings suggest that a minority of opioid-dependent people account for the majority of the criminal justice contact, in terms of both criminal charges and incarcerations. The custody setting also appeared to be an important opportunity to engage people in OST treatment. Furthermore, OST treatment, in prison and also immediately post-release, was found to be highly protective against mortality both while incarcerated and after release. Given these findings, and the other important benefits of OST, there is strong evidence to support the value of OST programs within the criminal justice system.