Mind wandering reflects the shift in attentional focus from task-related cognition driven by external stimuli toward self-generated and internally-oriented thought processes. Although such task-unrelated thoughts (TUTs) are pervasive and detrimental to task performance, their underlying neural mechanisms are only modestly understood. To investigate TUTs with high spatial and temporal precision, we simultaneously measured fMRI, EEG, and pupillometry in healthy adults while they performed a sustained attention task with experience sampling probes. Features of interest were extracted from each modality at the single-trial level and fed to a support vector machine that was trained on the probe responses. Compared to task-focused attention, the neural signature of TUTs was characterized by weaker activity in the default mode network but elevated activity in its anticorrelated network, stronger functional coupling between these networks, widespread increase in alpha, theta, delta, but not beta, frequency power, predominantly reduced amplitudes of late, but not early, event-related potentials, and larger baseline pupil size. Particularly, information contained in dynamic interactions between large-scale cortical networks was predictive of transient changes in attentional focus above other modalities. Together, our results provide insight into the spatiotemporal dynamics of TUTs and the neural markers that may facilitate their detection.