Several trials have demonstrated the efficacy of online cognitive behavioral therapy (CBT) for insomnia. However, few studies have examined putative mechanisms of change based on the cognitive model of insomnia. Identification of modifiable mechanisms by which the treatment works may guide efforts to further improve the efficacy of insomnia treatment. The current study therefore has two aims: (1) to replicate the finding that online CBT is effective for insomnia and (2) to test putative mechanism of change (i.e., safety behaviors and dysfunctional beliefs). Accordingly, we conducted a randomized controlled trial in which individuals with insomnia were randomized to either online CBT for insomnia (n = 36) or a waiting-list control group (n = 27). Baseline and posttest assessments included questionnaires assessing insomnia severity, safety behaviors, dysfunctional beliefs, anxiety and depression, and a sleep diary. Three- and six-month assessments were administered to the CBT group only. Results show moderate to large statistically significant effects of the online treatment compared to the waiting list on insomnia severity, sleep measures, sleep safety behaviors, and dysfunctional beliefs. Furthermore, dysfunctional beliefs and safety behaviors mediated the effects of treatment on insomnia severity and sleep efficiency. Together, these findings corroborate the efficacy of online CBT for insomnia, and suggest that these effects were produced by changing maladaptive beliefs, as well as safety behaviors. Treatment protocols for insomnia may specifically be enhanced by more focused attention on the comprehensive fading of sleep safety behaviors, for instance through behavioral experiments.