Objectives: Insomnia patients complain that mental events keep them awake. This study investigates how cognitive behavioural therapy (CBT) affects such events and considers how attributional, cognitive and psychopathological symptoms may mediate sleep improvement. Method: A pragmatic, parallel-group randomized controlled trial of 164 adults (120 F: (mean 49. years (18-78. years)) meeting Diagnostic and Statistical Manual of Mental Disorders, 5th Edition (DSM-5) criteria for insomnia disorder, assigned to CBT (n=55; 40 F), imagery relief therapy (IRT placebo; n=55; 42 F), or treatment as usual (TAU; n=54; 38 F), was conducted. CBT/IRT comprised six online sessions delivered by an animated therapist, with automated web/e-mail support. CBT users had access to a moderated community. TAU comprised 'usual care'. Participants completed the Sleep Disturbance Questionnaire (SDQ), Glasgow Content of Thoughts Inventory (GCTI), Depression Anxiety and Stress Scales (DASS) and Sleep Condition Indicator (SCI) at baseline, post treatment and 8-week follow-up. Results: The sample was characterised by mental arousal, notably 'trying too hard' to sleep (SDQ), and by 'sleep and sleeplessness' and 'rehearsal and planning' thoughts (GCTI). Treatment effects were observed for all SDQ domains (e.g., CBT vs. IRT: d=0.76 for 'trying too hard'). CBT was also superior to IRT on the GCTI (e.g., 'rehearsal and planning', d=0.62; 'sleep and sleeplessness', d=0.74). CBT vs. TAU comparisons yielded larger effects, whereas placebo effects (IRT vs. TAU) were small to moderate. Hierarchical regression demonstrated partial mediation of SCI improvement by attributional and cognitive factors (R2=21-27%) following CBT. Improvement in sleep efficiency appears to be independent of such factors. Conclusion: Online CBT modifies sleep-related attributions, night-time thought content and psychopathology. This process partly mediates improvement in DSM-5-defined insomnia. © 2014 Elsevier B.V.