Obesity is associated with a higher risk of several types of cancer, grouped as obesity-related cancers (ORC). Vitamin D deficiency is more prevalent in obese subjects, and it has been suggested to play a role in the association between obesity and cancer risk. The aim of the study was to analyze the association between vitamin D intake and the subsequent risk of ORC in a prospective Spanish cohort of university graduates. The SUN Project, initiated in 1999, is a prospective dynamic multipurpose cohort. Participants answered a 556-item lifestyle baseline questionnaire that included a validated food-frequency questionnaire. We performed Cox regression models to estimate the hazard ratios (HRs) of ORC according to quartiles of energy-adjusted vitamin D intake (diet and supplements). We included 18,017 participants (mean age = 38 years, SD = 12 years), with a median follow-up of 12 years. Among 206,783 person-years of follow-up, we identified 225 cases of ORC. We found no significant associations between vitamin D intake and ORC risk after adjusting for potential confounders: HRQ2vsQ1 = 1.19 (95% CI 0.81–1.75), HRQ3vsQ1 = 1.20 (95% CI 0.81–1.78), and HRQ4vsQ1 = 1.02 (95% CI 0.69–1.51). Dietary and supplemented vitamin D do not seem to be associated with ORC prevention in the middle-aged Spanish population.