The current study aimed to investigate the association between predicted vitamin D status and depression in a prospective Spanish cohort of university graduates. The SUN Project is a dynamic cohort study designed to investigate multiple aspects of health and lifestyle. Participants were asked to complete a comprehensive questionnaire consisting of 556 items, that included a validated food-frequency questionnaire. Participants initially free of depression were classified as incident cases if they reported a medical diagnosis of depression during follow-up. Serum vitamin D levels were predicted by a previously validated equation. Vitamin D deficiency was defined as vitamin D levels below 20 ng/mL. Cox models were used to estimate adjusted hazard ratios (HR) and 95% confidence intervals (95% CI). We included 15,175 Spanish university graduates [mean (SD) age: 36.9 year (11.5)] followed-up for a median of 12.7 years. Among 192,976 person-years of follow-up, we identified 753 incident cases of depression. Participants with vitamin D deficiency had a 27% higher risk of depression as compared to those with vitamin D sufficiency (HR: 1.27, 95% CI: 1.09–1.48; p = 0.002) after adjusting for potential confounders. Furthermore, a significant effect modification by female sex was observed with higher depression risks associated with vitamin D deficiency in women than in men (p for interaction = 0.034). In educated middle-aged Spanish adults, we observed a direct association between vitamin D deficiency and the risk of depression, that was stronger among women.