IntroductionWorking from home during the COVID-19 pandemic has been associated both with physical inactivity and musculoskeletal pain. However, it has not been examined whether physical activity and sedentary behavior are underlying mechanisms in the association between working from home and musculoskeletal pain. Therefore, we examined their mediating role in this association.MethodsData were used from 24 questionnaire rounds of the Lifelines COVID-19 cohort (March 2020–January 2022). Longitudinal information on work situation (location, home, hybrid), physical activity, sedentary behavior, and musculoskeletal pain was collected among 28,586 workers. Analysis of physical activity/sedentary behavior as mediators of the association between working from home and musculoskeletal pain was performed using multilevel structural equation modeling.ResultsHome workers more often had pain in the upper back [odds ratio (OR) = 1.17, 95%-confidence interval (CI) = 1.02–1.34] and arm, neck, and/or shoulder (ANS) (OR = 1.32, 95%-CI = 1.19–1.47) than location workers. Furthermore, home workers were more often sedentary for >9 h per work day than location workers (OR = 2.82, 95%-CI = 2.56–3.09), and being more sedentary was associated with musculoskeletal pain (upper back: OR = 1.17, 95%-CI = 1.06–1.30; ANS: OR = 1.25, 95%-CI = 1.16–1.34). Corresponding indirect effects were OR = 1.18 (95%-CI = 1.04–1.33) and OR = 1.26 (95%-CI = 1.12–1.35). No indirect effect was found for physical activity. Similar indirect effects were observed for hybrid workers.ConclusionHome and hybrid workers were more likely to have pain in the upper musculoskeletal system during the COVID-19 pandemic than location workers, which was partly mediated by increased sedentary behavior, but not by reduced physical activity. Measures to reduce sedentary time in home workers may contribute to preventing musculoskeletal pain.