For the past two decades, the USA has been embroiled in a growing prescription drug epidemic. The ripples of this epidemic have been especially apparent in the state of Maine, which has fought hard to mitigate the damage caused by addiction to pharmaceutical and illicit opioids. In this study, we construct a mathematical model of the opioid epidemic incorporating novel features important to better understanding opioid abuse dynamics. These features include demographic differences in population susceptibility, general transmission expressions, and combined consideration of pharmaceutical opioid and heroin abuse. We demonstrate the usefulness of this model by calibrating it with data for the state of Maine. Model calibration is accompanied by sensitivity and uncertainty analysis to quantify potential error in parameter estimates and forecasts. The model is analyzed to determine the mechanisms most influential to the number of opioid abusers and to find effective ways of controlling opioid abuse prevalence. We found that the mechanisms most influential to the overall number of abusers in Maine are those involved in illicit pharmaceutical opioid abuse transmission. Consequently, preventative strategies that controlled for illicit transmission were more effective over alternative approaches, such as treatment. These results are presented with the hope of helping to inform public policy as to the most effective means of intervention.© 2023. The Author(s), under exclusive licence to Society for Mathematical Biology.