BACKGROUND: Opioid use disorder (OUD) is a debilitating, chronic and costly disorder, and is increasingly prevalent in many countries. Maintenance opioid agonist therapy (OAT) with oral methadone or oral buprenorphine is the first-line, empirically-supported treatment. However, many patients do not stop taking illicit drugs during OAT. We developed a personalised psychosocial intervention (PSI) to select behaviour change methods tailored to patient need and preference. The aim was to determine if this PSI adjunctive to on-going OAT can help treatment-resistant patients achieve abstinence. METHODS: This was a pragmatic, open-label, randomised controlled trial at a specialist NHS community addictions clinic. We recruited adults meeting Diagnostic and Statistical Manual of Mental Disorders IV criteria for opioid and/or cocaine dependence, enrolled in OAT for a median of 26 weeks (IQR 10-88), voluntarily seeking continued OAT, who were treatmentresistant. Treatment resistance was defined as using illicit or nonmedical opioids and/or cocaine on one or more days in the past 28 days at screening, verified by urine drug screen. Participants were allocated (1:1) by a Clinical Trials Unit managed, webaccessed, password-protected, randomisation sequence (stratified by OAT medication, cocaine use, and drug injecting) to receive continued OAT and standard case management (treatment-as-usual, TAU) or OAT TAU and a psychology assistant-delivered personalised PSI. Treatment was provided open-label. Outcome data were collected by independent research assistants. The primary outcome was treatment response at 18 weeks, defined as abstinence from illicit and non-prescribed opioids and cocaine in the past 28 days recorded by Treatment Outcomes Profile and negative urine drug screen. Taking a societal cost perspective, the evaluation of cost-effectiveness was done by taking a wide range of values of willingness-to-pay (WTP) for a unit improvement in the probability of treatment response, and EQ-5D-3L derived quality adjusted life years (QALYs). The planned analysis was intention-to-treat (ITT), including all those who were randomly allocated. This trial is registered with the ISRCTN registry, number ISRCTN69313751. FINDINGS: Between June 7, 2013 and December 21, 2015, we randomly allocated 136 patients (50%) to the PSI group and 137 patients (51%) to the TAU group. The trial database was locked for analysis on April 19, 2017. In error, we re-randomised three participants. These cases were excluded from all analysis. Due to this error, the analysis is classified as a modified ITT (mITT). All other randomised participants were included. PSI was superior to TAU. In the mITT analysis, there were 22 responders (16·3%) among the 135 participants in the PSI group, and 9 responders (6·7%) among the 135 participants in the TAU group (adjusted log odds 1·20; 95% CI 0·01 to 2·37; p-value=0·005). PSI had a higher probability of being cost-effective than TAU. There was a probability range of 47% to 87% for WTP thresholds of £0 to £1,000. QALYs were higher in the PSI group than the TAU (mean difference 0·048 [95% CI 0·016 to 0·080]; p-value=0·004), with a 60% and 67% probability of cost-effectiveness at the NICE willingness to pay thresholds of £20,000 and £30,000 per QALY, respectively. In the TAU group, one participant (1%) died (hospitalised with acute sepsis) and another (1%) had a serious adverse event (hospitalised with head injury). In the PSI group, one participant (1%) had a serious adverse event (hospitalised with panic attack). None of these events was judged to be trial-related. INTERPRETATION: We found a personalised PSI for OAT-resistant patients, delivered by psychology assistants, was effective and had a higher probability of being cost-effective compared to TAU. Treatment-resistant patients should be offered personalised PSI. Trial Registration Number: This trial is registered with the ISRCTN registry, number ISRCTN69313751. Funding: Unrestricted research grant to Action on Addiction from Indivior. Declaration of Interest: JM is supported by research grants from the Department of Health, Institute for Health Research (NIHR), and the NIHR Biomedical Research Centre for Mental Health at South London and Maudsley NHS Mental Health Foundation Trust (SLaM). He has part-time employment as Senior Academic Advisor for the Alcohol, Drugs, Tobacco and Justice Division, Health and Wellbeing Directorate, Public Health England. He declares an unrestricted research grant funding at IoPPN and SLaM to Action on Addiction from Indivior for the present study, and grant support from NIHR for a trial of oral and extended-release naltrexone. JM has received honoraria from PCM Scientific in relation to the Improving Outcomes in Treatment of Opioid Dependence conference (2015-2018). He holds no stocks in any company. JH was supported by a National Institute for Health Research (NIHR) doctoral fellowship. MK, GS and LM declare unrestricted research grant funding at IoPPN and SLaM to Action on Addiction from Indivior for the present study. Ethical Approval: Ethical approval for the study was granted by the UK National Health Service (London-Bromley Research Ethics Committee: 13/LO/0640). Details of the study protocol and PSI have been published.