The ability to generate appropriate behaviors in response to changing situations requires both the alteration of ongoing behavior and the understanding of the global rules governing stimulus categorization in a given context. Neuropsychological tests that have been developed to measure this form of cognitive flexibility, such as the Wisconsin Card Sorting Test, have reliably demonstrated that individuals with lesions in regions of the prefrontal cortex and basal ganglia have difficulty generating a cognitive set and altering rule-governed behavior. Recent neuroimaging studies have supported the role of these brain regions in the performance of response shifting and cognitive set shifting. However, the precise role of these regions in the individual components of these tasks remains a contentious issue. Here, we used event-related functional magnetic resonance imaging (fMRI) to dissociate the neural circuitry involved in the alteration of ongoing behavior and the shifting of cognitive set. Participants viewed geometric shapes as they appeared individually in rapid succession and responded with an appropriate button press based upon whether the individual shape was a predetermined target stimulus. Responses were required for each shape presented. The fMRI results indicated that response shifting specifically activated a dorsal neural circuit comprised of the dorsolateral prefrontal cortex, anterior cingulate, and intraparietal sulcus. Shifts in cognitive set were mediated by ventrolateral prefrontal cortex, anterior cingulate, and striatum. These findings suggest that the alteration of ongoing behavior and shifting of cognitive set are mediated by two distinct neural systems interconnected by the anterior cingulate.