The Wisconsin Card Sorting Test (WCST) is the standard task paradigm to detect human frontal lobe dysfunction. In this test, subjects sort card stimuli with respect to one of three possible dimensions (color, form and number). These dimensions are changed intermittently, whereupon subjects are required to identify by trial and error a new correct dimension and flexibly shift cognitive set. We decomposed the cognitive requirements at the time of the dimensional changes of the WCST, using functional magnetic resonance imaging (fMRI). By explicitly informing subjects of a new correct dimension, the working memory load for the trial-and-error identification of the new dimension was removed. Event-related fMRI still revealed transient activation time-locked to the dimensional changes in areas in the posterior part of the inferior frontal sulci. However, the activation was significantly smaller than in the original WCST in which subjects had to use working memory to identify the new dimension by trial and error. Furthermore, these areas were found to spatially overlap the areas activated by a working memory task. These results suggest that working memory and set-shifting act cooperatively in the same areas of prefrontal cortex to adapt us to changing environments.