Vitamin D deficiency is common in many societies and causes rickets and non-skeletal disorders in children. There are no published data on vitamin D deficiency in Afghanistan. We, therefore, investigated the prevalence and associated factors of vitamin D deficiency in Afghan school children in Kandahar City, Afghanistan. This cross-sectional analytical study was conducted from September 2022 to April 2023 in 510 primary school students aged 6–15 years from six randomly selected schools. Data were analyzed by using descriptive statistics, Chi-square test, and multivariate logistic regression. Of the 510 enrolled children, 54.3% were boys and 91.8% were poor. The mean serum 25(OH)D concentration was 9.3 ng/mL. Vitamin D deficiency (< 20 ng/mL) was detected in 436/510 (85.5%) children that was severe in 267/510 (52.4%). By logistic regression analysis, independent factors for vitamin D deficiency were: (i) older age group 11–15 vs. 6 − 10 years, adjusted odds ratio (AOR) 2.8 (95% confidence interval 1.2–6.2), (ii) poverty AOR 2.0 (1.0–4.3), (iii) not doing outdoor physical activity AOR 4.8 (2.8–8.1), and (iv) daily sunlight exposure < 60 min AOR 2.2 (1.3–3.7). Although Kandahar is very sunny throughout the year, vitamin D deficiency is highly prevalent among school boys and girls, placing them at great risk of vitamin D-deficient rickets. More work is needed to define the country-wide prevalence of vitamin D deficiency to inform robust strategies of vitamin D supplementation, the provision of vitamin D-fortified food to the school children in Kandahar City and health education programs that can be conducted with the help of international organizations.