Among potential pathways to suicidal behavior in individuals with mental disorders (MD), work disability (WD) may play an important role. We examined the role of WD in the relationship between MD and suicidal behavior in Swedish-born individuals and refugees. The study cohort consisted of 4,195,058 individuals aged 16-64, residing in Sweden in 2004-2005, whereof 163,160 refugees were followed during 2006-2013 with respect to suicidal behavior. Risk estimates were calculated as hazard ratios (HR) with 95% confidence intervals (CI). The reference groups comprised individuals with neither MD nor WD. WD factors (sickness absence (SA) and disability pension (DP)) were explored as potential modifiers and mediators. In both Swedish-born and refugees, SA and DP were associated with an elevated risk of suicide attempt regardless of MD. In refugees, HRs for suicide attempt in long-term SA ranged from 2.96 (95% CI: 2.14-4.09) (no MD) to 6.23 (95% CI: 3.21-12.08) (MD). Similar associations were observed in Swedish-born. Elevated suicide attempt risks were also observed in DP. In Swedish-born individuals, there was a synergy effect between MD, and SA and DP regarding suicidal behavior. Both SA and DP were found to mediate the studied associations in Swedish-born, but not in refugees. There is an effect modification and a mediating effect between mental disorders and WD for subsequent suicidal behavior in Swedish-born individuals. Also for refugees without MD, WD is a risk factor for subsequent suicidal behavior. Particularly for Swedish-born individuals with MD, information on WD is vital in a clinical suicide risk assessment.