About 57 % of the pregnant European women have 25-hydroxyvitamin D (25(OH)D) concentrations below 50 nmol/l. However, as data on the impact of gestational vitamin D deficiency on maternal and fetal health are limited, the WHO does not advocate vitamin D supplementation as part of routine antenatal care. We explored associations between first trimester maternal 25(OH)D status and childhood cognition at 5–6 years of age (n 1854, primarily Caucasian). Median serum 25(OH)D was determined at 13 (interquartile range 12–14) weeks of gestation. Childhood attention, motor fluency and flexibility and executive function were assessed using the Amsterdam Neuropsychological Tasks. Restricted cubic splines and linear regression analyses were used to analyse the data while adjusting for many maternal and child related covariates. Higher 25(OH)D status (nmol/l) was associated with better attention and executive functioning as shown by a faster reaction time (β −0·30 (sd 0·14) ms, P=0·03), faster response speed (β −0·58 (sd 0·21) ms, P=0·006), and better response speed stability (β −0·45 (sd 0·17) ms, P=0·009). No associations were observed of serum 25(OH)D with motor fluency and flexibility. Associations were most pronounced among children of African origin (n 205) as compared with those of Caucasian or another origin, for example attention (reaction time, β −2·06 (sd 0·70) ms, P=0·004) and executive function (response speed, β −1·95 (sd 0·94) ms, P=0·04). Concluding, maternal 25(OH)D status was significantly associated with childhood attention and executive function, while no associations were observed for 25(OH)D status with motor fluency and flexibility.