Vitamin D is essential for several physiological functions and biological processes. Increasing levels of maternal vitamin D are required throughout pregnancy as a unique source of vitamin D for the fetus, and consequently maternal vitamin D deficiency may result in several adverse outcomes in newborns. However, the genetic regulation of vitamin D in pregnancy and at birth is not yet well understood. We performed genome-wide association studies of maternal midgestational serum-derived and neonatal blood-spot-derived total 25-hydroxyvitamin D from a case-control study of autism spectrum disorder (ASD). We identified one fetal locus (rs4588) significantly associated with neonatal vitamin D levels in the GC gene, encoding the binding protein for the transport and function of vitamin D. We also found suggestive cross-associated loci for neonatal and maternal vitamin D near immune genes, such as CXCL6-IL8 and ACKR1 We found no interactions with ASD. However, when including a set of cases with intellectual disability but not ASD (N = 179), we observed a suggestive interaction between decreased levels of neonatal vitamin D and a specific maternal genotype near the PKN2 gene. Our results suggest that genetic variation influences total vitamin D levels during pregnancy and at birth via proteins in the vitamin D pathway, but also potentially via distinct mechanisms involving loci with known roles in immune function that might be involved in vitamin D pathophysiology in pregnancy.