Human drug dependence routinely features a difficulty with disengaging attention from drug-related stimuli, a symptom previously shown to be predictive of relapse during treatment. We examined the neural mechanisms underlying this attentional bias in cocaine users, varying working memory (WM) load to reflect the demands imposed by ruminative craving thoughts. Sixteen active users of cocaine were administered a WM task that manipulated the requirement for selective attention by varying the background contents, cocaine-related or neutral, upon which a recall probe item was shown. Behavioural and fMRI data were collected. Cocaine users had significantly poorer attentional control under high WM demands, suffering both increased response times and reduced recall accuracy, with this effect more pronounced for cocaine stimuli (when compared to neutral stimuli). The presence of background cocaine stimuli was associated with increases in occipital cortex activity, consistent with increased visual processing of the irrelevant stimuli for these trials. In addition, the cocaine stimuli were associated with increased right prefrontal activity with those participants with higher levels of right prefrontal activity having lower levels of attentional bias. Cocaine users under high cognitive demands had difficulty modulating the neural mechanisms underlying cognitive control which appear necessary for restricting the visual processing of task-irrelevant, but salient drug-related, stimuli, a finding that may be relevant to identifying those at most risk of relapse.