Few studies have explored the relationship between dietary patterns and the risk of gestational diabetes mellitus (GDM). Evidence from non-Western areas is particularly lacking. In the present study, we aimed to examine the associations between dietary patterns and the risk of GDM in a Chinese population. A total of 3063 pregnant Chinese women from an ongoing prospective cohort study were included. Data on dietary intake were collected using a FFQ at 24–27 weeks of gestation. GDM was diagnosed using a 75 g, 2 h oral glucose tolerance test. Dietary patterns were determined by principal components factor analysis. A log-binomial regression model was used to examine the associations between dietary pattern and the risk of GDM. The analysis identified four dietary patterns: vegetable pattern; protein-rich pattern; prudent pattern; sweets and seafood pattern. Multivariate analysis showed that the highest tertile of the vegetable pattern was associated with a decreased risk of GDM (relative risk (RR) 0·79, 95 % CI 0·64, 0·97), compared with the lowest tertile, whereas the highest tertile of the sweets and seafood pattern was associated with an increased risk of GDM (RR 1·23, 95 % CI 1·02, 1·49). No significant association was found for either the protein-rich or the prudent pattern. The protective effect of a high vegetable pattern score was more evident among women who had a family history of diabetes (P for interaction = 0·022). These findings suggest that the vegetable pattern was associated with a decreased risk of GDM, while the sweets and seafood pattern was associated with an increased risk of GDM. These findings may be useful in dietary counselling during pregnancy.