BackgroundInsomnia disorder (ID) is one of the most common mental disorders. Research on ID focuses on exploring its mechanism of disease, novel treatments and treatment outcome prediction. An emerging technique in this field is the use of electroencephalography (EEG) microstates, which offer a new method of EEG feature extraction that incorporates information from both temporal and spatial dimensions.AimsTo explore the electrophysiological mechanisms of repetitive transcranial magnetic stimulation (rTMS) for ID treatment and use baseline microstate metrics for the prediction of its efficacy.MethodsThis study included 60 patients with ID and 40 age-matched and gender-matched good sleep controls (GSC). Their resting-state EEG microstates were analysed, and the Pittsburgh Sleep Quality Index (PSQI) and polysomnography (PSG) were collected to assess sleep quality. The 60 patients with ID were equally divided into active and sham groups to receive rTMS for 20 days to test whether rTMS had a moderating effect on abnormal microstates in patients with ID. Furthermore, in an independent group of 90 patients with ID who received rTMS treatment, patients were divided into optimal and suboptimal groups based on their median PSQI reduction rate. Baseline EEG microstates were used to build a machine-learning predictive model for the effects of rTMS treatment.ResultsThe class D microstate was less frequent and contribute in patients with ID, and these abnormalities were associated with sleep onset latency as measured by PSG. Additionally, the abnormalities were partially reversed to the levels observed in the GSC group following rTMS treatment. The baseline microstate characteristics could predict the therapeutic effect of ID after 20 days of rTMS, with an accuracy of 80.13%.ConclusionsOur study highlights the value of EEG microstates as functional biomarkers of ID and provides a new perspective for studying the neurophysiological mechanisms of ID. In addition, we predicted the therapeutic effect of rTMS on ID based on the baseline microstates of patients with ID. This finding carries great practical significance for the selection of therapeutic options for patients with ID.