Although the influence of long-term musical training on the processing of heard music has been the subject of many studies, the neural basis of music imagery and the effect of musical expertise remain insufficiently understood. By means of magnetoencephalography (MEG) we compared musicians and nonmusicians in a musical imagery task with familiar melodies. Subjects listened to the beginnings of the melodies, continued them in their imagination and then heard a tone which was either a correct or an incorrect further continuation of the melody. Only in musicians was the imagery of these melodies strong enough to elicit an early preattentive brain response to unexpected incorrect continuations of the imagined melodies; this response, the imagery mismatch negativity (iMMN), peaked approximately 175 ms after tone onset and was right-lateralized. In contrast to previous studies the iMMN was not based on a heard but on a purely imagined memory trace. Our results suggest that in trained musicians imagery and perception rely on similar neuronal correlates, and that the musicians' intense musical training has modified this network to achieve a superior ability for imagery and preattentive processing of music.