Abstract Background Major depressive disorder (MDD) onset strongly varies by socioeconomic position (SEP). One of the pathways that could explain the SEP-MDD onset relationship is via lifestyle factors, but little is known about this pathway. This study aims to disentangle the complex interplay between SEP measures, education, income and occupational prestige, and MDD development and to what extent the associations are mediated by lifestyle (related) factors, occupational and leisure time physical activity, smoking, alcohol intake, diet quality, sleep and central adiposity. Methods An adult subsample (n = 76,045) of the Lifelines Cohort Study without MDD at baseline was used. MDD onset was measured after a median follow-up time of 3.8 years with the Mini International Neuropsychiatric Interview (MINI). Direct associations between the SEP measures, the lifestyle factors and MDD onset were estimated, independent of age, sex, depression history and time between baseline and second assessment, using logistic regression analyses. Mediating percentages were estimated using the Karlson-Holm-Breen method. Results A total of 1,864 participants (2.5%) developed MDD during follow-up. Education, income and occupational prestige were inversely associated with MDD onset. Educational differences in MDD onset were for 18.7% explained by lifestyle factors, with smoking (9.1%) and central adiposity (6.7%) being the strongest mediating factors. Income differences in MDD onset were for 5.9% explained by lifestyle factors, with alcohol intake (4.0%) and central adiposity (2.6%) being the strongest mediating factors. Occupational prestige differences in MDD onset were not explained by lifestyle factors. Conclusions Individuals with a higher education, income or occupational prestige had a lower risk of MDD onset compared to their lower SEP counterparts. This was mainly due to a healthier lifestyle, with smoking, alcohol intake and central adiposity being the most important factors. Key messages Education, income and occupational prestige were inversely associated with MDD onset. Educational and income differences were mainly explained by smoking, alcohol intake and central adiposity.