Vitamin D stimulates production of the endogenous antimicrobial peptides cathelicidin and β-defensin-2, which are expressed in the urinary tract. We investigated vitamin D status and levels of cathelicidin and β-defensin-2 and their association with urinary tract infection (UTI). The study included 120 children under three years of age: 76 children with UTIs and 44 otherwise healthy children with congenital hydronephrosis. Serum 25-hydroxycholecalciferol levels were measured by direct competitive electro-chemiluminescence immunoassay, and plasma cathelicidin and β-defensin-2 concentrations were analysed by enzyme-linked immunosorbent assay. We found that vitamin D insufficiency and deficiency are prevalent in young children (21%). Serum vitamin D levels negatively correlated with age and were significantly lower in girls. Levels of vitamin D positively correlated with levels of cathelicidin but not with β-defensin-2. Low concentrations of vitamin D were associated with UTIs in girls, but we did not see any correlation with the recurrence of infection at one-year follow-up. Vitamin D deficiency is common and may prove to be a risk factor for UTIs especially in girls. We hypothesise that adequate supplementation with vitamin D may become a way to prevent first-time UTIs. ©2018 Foundation Acta Paediatrica. Published by John Wiley & Sons Ltd.