BACKGROUND: Repetitive transcranial magnetic stimulation (rTMS) has the potential to increase the clinical effect of exposure with response prevention psychotherapy for obsessive-compulsive disorder (OCD). We investigated the use of task-based functional magnetic resonance imaging for predicting clinical outcomes to different rTMS protocols combined with exposure with response prevention in OCD. METHODS: Sixty-one adults with OCD underwent rTMS and exposure with response prevention and were randomized to different high-frequency rTMS conditions: left dorsolateral prefrontal cortex (n = 19), left presupplementary motor area (n = 23), and control stimulation at the vertex at low intensity (n = 19). The Tower of London task and stop signal task were used to assess pretreatment activation during planning and inhibitory control, respectively. We adopted a Bayesian region-based approach to test whether clinical improvement can be predicted by task-based functional magnetic resonance imaging-derived measures of task-related brain activation or functional connectivity between task-relevant regions and the bilateral amygdala. RESULTS: For the vertex group, but not the dorsolateral prefrontal cortex/presupplementary motor area rTMS conditions, higher activation in several task-relevant regions during planning and response inhibition and lower error-related activation corresponded with better short-term clinical improvement. Lower precuneus activation with increased planning taskload was correlated with symptom reduction in the dorsolateral prefrontal cortex group. In the presupplementary motor area group, higher error-related activation and lower inhibition-related insular-amygdalar connectivity were associated with symptom reduction. CONCLUSIONS: Pretreatment task-based functional magnetic resonance imaging-derived measures of activation and connectivity during planning and inhibition-related processes are associated with clinical response for specific rTMS conditions in OCD. Future placebo-controlled trials with larger sample sizes should combine clinical information and neural correlates to improve prediction of clinical outcome.