Background: Vitamin D has been implicated as being important for maintaining cognitive function in old age. Results from longitudinal studies examining the association of vitamin D with incident dementia and cognitive impairment have been inconsistent. Objective: We investigated the relation between vitamin D, assessed in 3 different ways, and the risk of dementia. Design: We measured plasma 25-hydroxyvitamin D [25(OH) D] with the use of high-performance liquid chromatography-mass spectrometry, assessed dietary vitamin D intake with the use of 7-d dietary records, and created a vitamin D-synthesis genetic risk score (GRS) at baseline (1991-1995) in a cohort of 1182 Swedish men (mean age: 71 y). In a maximum of 18 y (median: 12 y) of follow-up, 116 men developed Alzheimer disease, 64 men developed vascular dementia, and 250 men developed all-cause dementia. An additional 80 men declined in cognitive function as assessed with the use of the Mini-Mental State Examination. Adjusted HRs and ORs were calculated with the use of Cox and logistic regressions. Results: The mean +/- SD plasma 25(OH) D concentration was 68.7 +/- 19.1 nmol/L. Plasma 25(OH) D, dietary vitamin D intake, and vitamin D-synthesis GRS were not associated with any cognitive outcomes (crude and adjusted HRs and ORs were similar to 1.0 for all continuous exposures). The adjusted HR for all-cause dementia was 0.88 (95% CI: 0.59, 1.31) in men with plasma 25(OH) D concentrations75 nmol/L. The adjusted HR for all-cause dementia was 0.92 (95% CI: 0.63, 1.32) for the lowest compared with highest tertiles of vitamin D intake. The adjusted HR for the continuous GRS for all-cause dementia was 1.04 (95% CI: 0.91, 1.19). Conclusion: In this cohort study, we show that there is no association between baseline vitamin D status and long-term risk of dementia or cognitive impairment over an 18-y period of time.