This study aimed to describe diet quality of pregnant women and explore the association between maternal diet and the prevalence of low birth weight (LBW) and small for gestational age (SGA). A total of 3856 participants from a birth cohort in Beijing, China, were recruited between June 2018 and February 2019. Maternal diet in the first and second trimesters was assessed by the Chinese diet balance index for pregnancy (DBI-P), using data collected by the inconsecutive 2-d 24-h dietary recalls. Logistic regressions were performed to explore the independent effects of DBI-P components on LBW and SGA. The prevalence of LBW and SGA was 3·8% and 6·0%, respectively. Dietary intakes of the participants were imbalanced. The proportions of participants having insufficient intake of vegetables (87·3% and 86·6%), dairy product (95·9% and 96·7%) and aquatic foods (80·5% and 85·3%) were high in both trimesters. The insufficiency of fruit intake was more severe in the second (85·2%) than that in the first trimester (22·5%) (P < 0·05). After adjusting for potential confounders, the intake of fruits and dairy in the second trimester was negatively associated with the risk of LBW (OR = 0·850, 95% CI: 0·723, 0·999) and SGA (OR = 0·885, 95% CI: 0·787, 0.996), respectively. Sufficient consumption of fruits and dairy products in pregnancy may be suggested in order to prevent LBW and SGA.