Purpose A growing body of evidence shows that consumption of ultra-processed foods (UPF) is associated with a higher risk of cardiometabolic diseases, which, in turn, have been linked to depression. This suggests that UPF might also be associated with depression, which is among the global leading causes of disability and disease. We prospectively evaluated the relationship between UPF consumption and the risk of depression in a Mediterranean cohort. Methods We included 14,907 Spanish university graduates [mean (SD) age: 36.7 year (11.7)] initially free of depression who were followed up for a median of 10.3 years. Consumption of UPF (industrial formulations made mostly or entirely from substances derived from foods and additives, with little, if any, intact food), as defined by the NOVA food classification system, was assessed at baseline through a validated semi-quantitative 136-item food-frequency questionnaire. Participants were classified as incident cases of depression if they reported a medical diagnosis of depression or the habitual use of antidepressant medication in at least one of the follow-up assessments conducted after the first 2 years of follow-up. Cox regression models were used to assess the relationship between UPF consumption and depression incidence. Results A total of 774 incident cases of depression were identified during follow-up. Participants in the highest quartile of UPF consumption had a higher risk of developing depression [HR (95% CI) 1.33 (1.07-1.64); p trend = 0.004] than those in the lowest quartile after adjusting for potential confounders. Conclusions In a prospective cohort of Spanish university graduates, we found a positive association between UPF consumption and the risk of depression that was strongest among participants with low levels of physical activity.