This study assessed the efficacy of repetitive transcranial magnetic stimulation (rTMS) in the treatment of patients with chronic primary insomnia. Hundred and twenty patients with chronic primary insomnia were randomly assigned to three study groups (n = 40 per group): rTMS, medication, or psychotherapy treatment (both latter as controls). The treatments proceeded for 2 weeks, after which treatment efficacies were assessed in each study group based on changes in polysomnography parameters, Pittsburgh sleep quality index, and indices of HPA and HPT axes (serum cortisol, adrenocorticotropic hormone, highly sensitive thyrotropin, free T3, and free T4). Further, the relapse and recurrence rates within 3 months after respective treatments were also measured. rTMS treatment significantly better (p < 0.05) improved stage III sleep and REM sleep cycle compared with both control groups. Further, rTMS treatment group was more advantageous in improving the indices of HPA and HPT axes (p < 0.05 vs. both control groups). In addition, the relapse and recurrence rates were also the lowest in rTMS treatment group. In conclusion, rTMS treatment is more advantageous than both medication and psychotherapy treatments in improving the sleep architecture. Further, rTMS significantly decreases the body awakening level and provides a better long-term treatment effect.