Background: The 'healthy worker effect' predicts that longer employment is positively associated with reduced mortality, but few studies have examined mortality in military veterans irrespective of exposure to conflict. Aims: To examine mortality in a large national cohort of Scottish veterans by length of service. Methods: Retrospective cohort study comparing survival in up to 30 years follow-up among 57,000 veterans and 173,000 people with no record of service, matched for age, sex and area of residence, who were born between 1945 and 1985. We compared antecedent diagnoses in the two groups to provide information on probable risk factors. Results: By the end of follow-up, 3,520 (6%) veterans had died, compared with 10,947 (6%) non-veterans. Cox proportional hazard analysis confirmed no significant difference overall unadjusted or after adjusting for deprivation. On subgroup analysis, those who left prematurely (early service leavers) were at significantly increased risk of death, hazard ratio 1.16, 95% confidence intervals 1.09-1.24, P<0.001, although the increase became nonsignificant after adjusting for socioeconomic status, hazard ratio 1.05, 95% confidence intervals 0.99-1.12. Longer-serving veterans were at significantly lower risk of death than non-veterans; the risk decreased both with length of service and in more recent birth cohorts. Smoking-related disease was the greatest contributor to increased mortality in early leavers. Conclusion: Among longer-serving veterans, there was evidence of a 'healthy worker effect' partly attributable to selective attrition of early service leavers, but birth cohort analysis suggests improvements over time which may also reflect a causal effect of improved inservice health promotion.