Little is known about the neural mechanisms that control attentional modulation of deviance detection in the auditory modality. In this study, we manipulated the difficulty of a primary task to test the relation between task difficulty and the detection of infrequent, task-irrelevant deviant (D) tones (1300 Hz) presented among repetitive standard (S) tones (1000 Hz). Simultaneous functional magnetic resonance imaging (fMRI)/event-related potentials (ERPs) were recorded from 21 subjects performing a two-alternative forced-choice duration discrimination task (short and long tones of equal probability). The duration of the short tone was always 50 msec. The duration of the long tone was 100 msec in the easy task and 60 msec in the difficult task. As expected, response accuracy decreased and response time (RT) increased in the difficult compared with the easy task. Performance was also poorer for D than for S tones, indicating distraction by task-irrelevant frequency information on trials involving D tones. In the difficult task, an amplitude increase was observed in the difference waves for N1 and P3a, ERP components associated with increased attention to deviant sounds. The mismatch negativity (MMN) response, associated with passive deviant detection, was larger in the easy task, demonstrating the susceptibility of this component to attentional manipulations. The fMRI contrast D > S in the difficult task revealed activation on the right superior temporal gyrus (STG) and extending ventrally into the superior temporal sulcus, suggesting this region's involvement in involuntary attention shifting toward unattended, infrequent sounds. Conversely, passive deviance detection, as reflected by the MMN, was associated with more dorsal activation on the STG. These results are consistent with the view that the dorsal STG region is responsive to mismatches between the memory trace of the standard and the incoming deviant sound, whereas the ventral STG region is activated by involuntary shifts of attention to task-irrelevant auditory features.