UNLABELLED: AIM To compare retention in treatment and mortality among people entering methadone and buprenorphine treatment for opioid dependence. DATA SOURCES: The Pharmaceutical Drugs of Abuse System (PHDAS) database records start- and end-dates of all episodes of methadone and buprenorphine treatment in New South Wales, and the National Death Index (NDI) records all reported deaths. METHODS: Data linkage study. First entrants to treatment between June 2002 and June 2006 were identified from the PHDAS database. Retention in treatment was compared between methadone and buprenorphine. Names were linked to the NDI database, and 'good matches' were identified. Deaths were classified as occurring during induction, maintenance and either post-methadone or post-buprenorphine, depending on the latest episode of treatment prior to death. The numbers of inductions into treatment, of total person-years spent in each treatment, and person-years post-methadone or buprenorphine, were calculated. Risk of death in different periods, and different treatments, was analysed using Poisson regression. RESULTS: A total of 5992 people entered their first episode of treatment-3349 (56%) on buprenorphine, 2643 on methadone. Median retention was significantly longer in methadone (271 days) than buprenorphine (40 days). During induction, the risk of death was lower for buprenorphine (relative risk = 0.114, 95% confidence interval = 0.002-0.938, P = 0.02, Fisher's exact test). Risk of death was lowest during treatment, significantly higher in the first 12 months after leaving both methadone and buprenorphine. Beyond 12 months after leaving treatment, risk of death was non-significantly higher than during treatment. CONCLUSIONS: Buprenorphine was safer during induction. Despite shorter retention in treatment, buprenorphine maintenance was not associated with higher risk of death.