BackgroundThe growing demand for labour flexibility has resulted in decreasing employment stability that could be associated with poor mental health status. Few studies have analysed the whole of the work force in considering this association since research on flexible forms of employment traditionally analyses employed and unemployed people separately. The gender division of work, and family characteristics related to employment situation, could modify its association with mental wellbeing. The objective of the study was to examine the relationship between a continuum of employment stability and mental health taking into account gender and partner/marital status.MethodsWe selected 6859 men and 5106 women currently salaried or unemployed from the 2006 Spanish National Health Survey. Employment stability was measured through a continuum from the highest stability among employed to lowest probability of finding a stable job among the long-term unemployed. Mental health was measured with the 12-item version of the General Health Questionnaire. Logistic regression models were fitted for each combination of partner/marital status and gender.ResultsIn all groups except among married women employment stability was related to poor mental health and a gradient between a continuum of employment stability and mental health status was found. For example, compared with permanent civil servants, married men with temporary contract showed an aOR = 1.58 (95%CI = 1.06–2.35), those working without a contract aOR = 2.15 (95%CI = 1.01–4.57) and aOR = 3.73 (95%CI = 2.43–5.74) and aOR = 5.35 (95%CI = 2.71–10.56) among unemployed of up to two years and more than two years, respectively. Among married and cohabiting people, the associations were stronger among men. Poor mental health status was related to poor employment stability among cohabiting women but not among married ones. The strongest association was observed among separated or divorced people.ConclusionsThere is a rise in poor mental health as the distance from stable employment grows. This result differs according to the interaction with gender and partner/marital status. In Spain this relationship seems to follow a pattern related to the gender division of work in married people but not in other partner/marital situations. Family and socioeconomic context can contribute to explain previous mixed results. Recommendations for research and for action are given.Electronic supplementary materialThe online version of this article (10.1186/s12889-018-5282-3) contains supplementary material, which is available to authorized users.