AimTo assess whether the introduction of a prison‐based opioid substitution therapy (OST) policy was associated with a reduction in drug‐related deaths (DRD) within 14 days after prison release.DesignLinkage of Scotland's prisoner database with death registrations to compare periods before (1996–2002) and after (2003–07) prison‐based OST was introduced.SettingAll Scottish prisons.ParticipantsPeople released from prison between 1 January 1996 and 8 October 2007 following an imprisonment of at least 14 days and at least 14 weeks after the preceding qualifying release.MeasurementsRisk of DRD in the 12 weeks following release; percentage of these DRDs which occurred during the first 14 days.FindingsBefore prison‐based OST (1996–2002), 305 DRDs occurred in the 12 weeks after 80 200 qualifying releases, 3.8 per 1000 releases [95% confidence interval (CI) = 3.4–4.2]; of these, 175 (57%) occurred in the first 14 days. After the introduction of prison‐based OST (2003–07), 154 DRDs occurred in the 12 weeks after 70 317 qualifying releases, a significantly reduced rate of 2.2 per 1000 releases (95% CI = 1.8–2.5). However, there was no change in the proportion which occurred in the first 14 days, either for all DRDs (87: 56%) or for opioid‐related DRDs.ConclusionsFollowing the introduction of a prison‐based opioid substitution therapy (OST) policy in Scotland, the rate of drug‐related deaths in the 12 weeks following release fell by two‐fifths. However, the proportion of deaths that occurred in the first 14 days did not change appreciably, suggesting that in‐prison OST does not reduce early deaths after release.