Music is a ubiquitous phenomenon in human cultures, mostly due to its power to evoke and regulate emotions. However, effects of music evoking different emotional experiences such as sadness and happiness on cognition, and in particular on self-generated thought, are unknown. Here we use probe-caught thought sampling and functional magnetic resonance imaging (fMRI) to investigate the influence of sad and happy music on mind-wandering and its underlying neuronal mechanisms. In three experiments we found that sad music, compared with happy music, is associated with stronger mind-wandering (Experiments 1A and 1B) and greater centrality of the nodes of the Default Mode Network (DMN) (Experiment 2). Thus, our results demonstrate that, when listening to sad vs. happy music, people withdraw their attention inwards and engage in spontaneous, self-referential cognitive processes. Importantly, our results also underscore that DMN activity can be modulated as a function of sad and happy music. These findings call for a systematic investigation of the relation between music and thought, having broad implications for the use of music in education and clinical settings.