Only one prospective study has analysed the relationship between the inflammatory properties of diet and risk of depression thus far. The aim of this study was to assess the association between the dietary inflammatory index (DII) and the incidence of depression. In a cohort study of 15 093 university graduates, participants completed a validated FFQ at baseline and after 10 years of follow-up. The DII was calculated based on the FFQ. Each of the twenty-eight nutrients or foods received a score based on findings from the peer-reviewed literature reporting on the relationships between diet and inflammatory biomarkers (IL-1β, IL-4, IL-6, IL-10, TNF-α and C-reactive protein). Participants were classified as having depression if they reported a new clinical diagnosis of depression by a physician, antidepressant drugs, or both. Multivariable Cox regression models were used to estimate hazard ratios (HR) of depression according to quintiles of the DII. After a median 8·5 years of follow-up, we observed 1051 incident cases of depression. The HR for participants in the highest quintile of DII (strongly pro-inflammatory) was 1·47 (95 % CI 1·17, 1·85) compared with those in the bottom quintile, with a significant dose–response relationship (Ptrend=0·01). In the subgroup analyses, the association between DII and depression was stronger among participants >55 years and among those with cardiometabolic comorbidities (HR 2·70; 95 % CI 1·22, 5·97 and HR 1·80; 95 % CI 1·27, 2·57, respectively). A pro-inflammatory diet was associated with a significantly higher risk of depression in a Mediterranean population. This association was stronger among older subjects and subjects with cardiometabolic diseases.