Sleep disorders are common in children with autism spectrum disorder (ASD). Transcranial magnetic stimulation (TMS) can influence the excitability of neuronal cells in stimulated areas, leading to improvements in sleep and other autistic symptoms. However, studies on clinical mechanisms of TMS in treating sleep disorders associated with ASD are limited. Therefore, we aimed to explore the effects of TMS on sleep structure and quality in children with ASD. Between January 2020 and December 2021, recruitment was advertised through child and adolescent outpatient clinics and online platforms by the Hangzhou Seventh People's Hospital and Lishui Second People's Hospital. Sixty children with ASD who met the diagnostic criteria of the Diagnostic and Statistical Manual of Mental Disorders, Fifth Edition, were selected and randomly divided into the active TMS and sham TMS treatment groups. Thirty healthy children of the same age were recruited as controls. The active TMS group received bilateral low-frequency (0.5Hz) TMS targeting the dorsolateral prefrontal cortex on both sides in children with ASD, whereas the sham TMS group received sham stimulation with the same stimulation time and location as the experimental group. Both groups were treated for 6 weeks, and the participants were assessed using the Sleep Disturbance Scale for Children (SDSC) before treatment, at 3 weeks, and at 6 weeks of intervention. Independent sample t-tests and difference t-tests were used for statistical analysis of the data. No significant differences were observed in general demographic variables, such as age and sex, between the ASD and control groups (P>0.05). Independent sample t-test analysis showed that the total SDSC score, difficulty falling asleep, sleep maintenance, awakening disorders, sleep-wake transition disorders, excessive daytime sleepiness, and nocturnal hyperhidrosis scores were significantly higher in the ASD group than in the control group (P<0.05). Before treatment, no significant differences were observed in the factor or total SDSC scores between the sham TMS group and the active TMS group (P>0.05). After 15 and 30 treatment sessions, the total SDSC score, difficulty falling asleep, sleep maintenance, sleep-wake transition disorders, and excessive daytime sleepiness scores were significantly higher in the sham TMS group than in the active TMS group (P<0.05). The difference t-test analysis showed that after 30 treatment sessions, the reduction rates of the total SDSC score, difficulty falling asleep, sleep maintenance, awakening disorders, sleep-wake transition disorders, excessive daytime sleepiness, and nocturnal hyperhidrosis dimensions were significantly higher in the active TMS group than in the sham TMS group (P<0.05). Low-frequency TMS targeting the dorsolateral prefrontal cortex in children with ASD can effectively improve their sleep status, and significant improvement can be achieved after 6 weeks (30 sessions) of treatment.