Background. Studies on depression and mortality in nursing homes have shown inconclusive findings, and none has studied the role of detection. We sought to measure the association of depression with long-term all-cause mortality in institutionalised older people and evaluate a potential modification in the association by its detection status.Methods. We selected a stratified cluster sample of 591 residents aged 75 years or older (mean age 84.5 years) living in residential and nursing homes of Madrid, Spain, who were free of severe cognitive impairment at the 1998-1999 baseline interview. Mortality was ascertained until age 105 years or September 2013 (median/maximum follow-up 4.8/15.2 years) through linkage to the Spanish National Death Index. Detected depression was defined at baseline as a physician's diagnosis or antidepressant use, undetected depression as significant depressive symptoms (score of 4 or higher on the ten-item version of the Geriatric Depression Scale) without documented diagnosis or treatment, and no depression as the absence of diagnosis, treatment, and symptoms. Constant and age-dependent hazard ratios for mortality comparing detected and undetected depression with no depression were estimated using Cox models, and absolute years of life gained and lost using Weibull models.Results. The baseline prevalences of detected and undetected depression were 25.9 and 18.8%, respectively. A total of 499 participants died during 3575 person-years of follow-up. In models adjusted for age, sex, type of facility, number of chronic conditions, and functional dependency, overall depression was not associated with long-term all-cause mortality (hazard ratio 0.87, 95% confidence interval (CI): 0.70-1.08). However, compared with no depression, detected depression showed lower mortality (hazard ratio 0.63, 95% CI: 0.46-0.86), while undetected depression registered higher, not statistically significant, mortality (hazard ratio 1.35, 95% CI: 0.98-1.86). The median life expectancy increased by 1.8 years (95% CI: −3.1 to 6.7 years) in residents with detected depression and decreased by 6.3 years (95% CI: 2.6-10.1 years) in those undetected. Results were more marked in women than men and they were robust to the exclusion of antidepressants from the definition of depression and also to the use of a stricter cut-off for the presence of depressive symptoms.Conclusions. The long-term mortality risk associated with depression in nursing homes depends on its detection status, with better prognosis in residents with detected depression and worse in those undetected. The absolute impact of undetected depressive symptoms in terms of life expectancy can be prominent.