BackgroundSleep problems (insomnia) and chronic pain are associated. Chronic pain and insomnia/insufficient sleep quality share similar symptoms and features. Although they have a bidirectional relationship, more research is needed to understand how they interact via mediators and how moderators influence this relationship.AimsIn this large clinical registry-based cohort study (N = 6,497), we investigate important mediators between insomnia and pain intensity in a cross-sectional sample of chronic pain patients using advanced path analysis. In addition, we investigate whether some background variables were moderators of the identified important paths or not and the correlation patterns between insomnia and pain intensity in relation to the mediators.MethodsThis study includes a cohort of adult patients with chronic non-cancer pain from the Swedish Quality Registry for Pain Rehabilitation (SQRP) with data on patient-reported outcome measures (PROMs) (2008-2016). The PROMs cover the background, pain aspects, psychological distress, pain-related cognitions, activity/participation, and health-related quality of life variables of the patients. Partial least squares structural equation modeling was used to explore the direct and indirect (via mediators) relationships between insomnia and pain intensity at baseline.ResultsIn this cohort study, insomnia was prevalent at 62.3%, and both direct and indirect mediating paths were present for the insomnia-pain intensity relationship. All of the mediating effects combined were weaker than the direct effect between insomnia and pain intensity. The mediating effects via catastrophizing and acceptance showed the strongest and equal mediating paths, and mediating effects via fear avoidance were the second strongest. Insomnia showed stronger direct significant correlations with psychological distress, catastrophizing, and acceptance compared with those of pain intensity. Sex, age, education level, spatial extent of pain, or body mass index did not moderate the mediating paths.Discussion and conclusionThis study confirms the existence of significant direct and mediating paths between reported insomnia and pain intensity. Future studies should focus on illuminating how sleep interventions influence pain intensity and other important key factors that contribute to the distress of chronic pain patients.