The causal nature of the association between hypovitaminosis D and poor cognitive function in mid- to later-life is uncertain. Using a Mendelian randomisation(MR) approach, we examined the causal relationship between 25(OH)D and cognitive function. Data came from 172,349 participants from 17 cohorts. DHCR7(rs12785878), CYP2R1 rs12794714) and their combined synthesis score were chosen to proxy 25(OH)D. Cognitive tests were standardised into global and memory scores. Analyses were stratified by 25(OH)D tertiles, sex and age. Random effects meta-analyses assessed associations between 25(OH)D and cognitive function. Associations of serum 25(OH)D with global and memory-related cognitive function were non-linear (lower cognitive scores for both low and high 25(OH)D, p curvature ≤ 0.006), with much of the curvature attributed to a single study. DHCR7, CYP2R1, and the synthesis score were associated with small reductions in 25(OH)D per vitamin D-decreasing allele. However, coefficients for associations with global or memory-related cognitive function were non-significant and in opposing directions for DHCR7 and CYP2R1, with no overall association observed for the synthesis score. Coefficients for the synthesis score and global and memory cognition were similar when stratified by 25(OH)D tertiles, sex and age. We found no evidence for serum 25(OH)D concentration as a causal factor for cognitive performance in mid- to later life.