Opioids prescribed in hospital are a key risk factor for harm in the community. This study aimed to gain an in-depth understanding of factors affecting post-operative opioid prescribing amongst clinicians using the capability, opportunity, motivation generate behaviour framework, more commonly known as COM-B. Focus groups and semi-structured interviews were used to gain an in-depth understanding of factors affecting optimal practice when prescribing opioids for post-operative patients at discharge. A topic guide was written using the COM-B behaviour change model to ensure the full range of possible factors influencing prescribing behaviours were explored. We found barriers and facilitators of optimal opioid prescribing practice across all three domains of capability, opportunity and motivation. Capability among junior doctors could be increased in the areas of risk assessment and prescribing appropriate discharge analgesia, though education and training were not key barriers to improving practice. Findings indicated that opportunity to practice optimal prescribing was hindered by a lack of time at discharge and technology. Beliefs about one's own and others' responsibilities also impacted motivation to practice optimal prescribing behaviours. Pharmacists were identified as key supports for patient education and appropriate prescribing. Educating prescribers about opioid risks and clinical practice guidelines are necessary interventions, however, our findings indicate that if implemented in isolation, they may not have the desired impact. Interventions also need to address discharge time pressures and presumptions that GPs are aware of whether opioids should be ceased or continued after surgical discharge.