We conducted an observational study to assess the prevalence and risk factors of vitamin D deficiency in 12–24 months old children living in urban and rural Bangladesh. Serum 25-hydroxyvitamin D (free 25(OH)D) level, socio-demographic status, anthropometric status, dietary intake, exposure to sunlight and single nucleotide polymorphisms in vitamin-D pathway genes were measured in 208 children. Vitamin D deficiency (free 25(OH)D < 50 nmol/l) was reported in 47% of the children. Multivariable logistic regression model identified duration to sunlight exposure (regression coefficient, β = − 0.01; 95% CI 0.00, − 0.02; p-value < 0.05), UV index (β = − 0.36; 95% CI 0.00, − 0.02; p-value < 0.05) and breast-feeding (β = − 1.15; 95% CI − 0.43, − 1.86; p-value < 0.05) to be negatively associated with vitamin D deficiency. We measured the role of single nucleotide polymorphisms in pathway genes (GC-rs7041 T > G, rs4588 C > A, CYP2R1-rs206793 A > G, CYP27B1-rs10877012 A > C and DHCR7-rs12785878 G > T) and found statistically significant differences in serum vitamin D levels between various genotypes. SNPs for CYP27B1 (CA & CC genotype) had statistically significant positive association (β = 1.61; 95% CI 2.79, 0.42; p-value < 0.05) and TT genotype of GC-rs7041 had negative association (β = − 1.33; 95% CI − 0.02, − 2.64; p-value < 0.05) with vitamin-D deficiency in the surveyed children.