There has been growing concern about the negative mental health impact of long working hours and overwork. Our study examined how work-life imbalance (WLI) could be a mediator between working hours and poor mental well-being. We included 34,968 individuals from a nationwide cross-sectional survey in Korea. Self-reported working hours per week were collected, and mental health was assessed using the World Health Organization (WHO)-5 Well-Being Index. Counterfactual-based mediation models were employed to disentangle the total effects into a direct effect (work hour - poor mental health) and an indirect effect (work hour - WLI - poor mental health). Out of 34,968 participants, 52.6% worked 35-40 hours/week, 20.0% worked 41-48 hours/week, 11.7% worked 49-54 hours/week, and 15.6% worked ≥55 hours/week. The odds ratios (ORs) of the total impact of working hours on poor mental health were 1.08 (95% confidence interval [CI], 1.01-1.16) for 41-48 hours/week, 1.28 (95% CI, 1.17-1.39) for 49-54 hours/week, and 1.60 (95% CI, 1.48-1.74) for ≥55 hours/week in comparison to 35-40 hours/week. The ORs of the indirect effects were 1.04 (95% CI, 1.03-1.05) for 41-48 hours/week, 1.08 (95% CI, 1.07-1.09) for 49-54 hours/week, and 1.14 (95% CI, 1.12-1.16) for ≥55 hours/week, accounting for 51%, 31%, and 28% of the total effects, respectively. Our findings suggest that WLI can partially mediate the association of long working hours with mental health deterioration. Policy efforts are required to mitigate the adverse mental health effects of overwork.