Maternal dietary patterns and macronutrients intake have been shown to affect the development of gestational diabetes mellitus (GDM), but the findings are inconsistent. We aimed to identify maternal dietary patterns and examine their associations with GDM risk, and to evaluate the contributions of macronutrients intake to these associations. We included 2755 Chinese pregnant women from the Tongji Maternal and Child Health Cohort. Dietary intakes were assessed using a validated semi-quantitative FFQ 2 weeks before the diagnosis of GDM. GDM (n 248) was diagnosed based on the results of a 75-g, 2-h oral glucose tolerance test at 24–28 weeks gestation. We derived five different dietary patterns from a principal component analysis. The results showed that high fish–meat–eggs scores, which were positively related to protein intake and inversely related to carbohydrate intake, were associated with a higher risk of GDM (adjusted OR for quartile 4 v. quartile 1: 1·83; 95 % CI 1·21, 2·79; Ptrend=0·007) and higher plasma glucose levels. In contrast, high rice–wheat–fruits scores, which were positively related to carbohydrate intake and inversely related to protein intake, were associated with lower risk of GDM (adjusted OR for quartile 3 v. quartile 1: 0·54; 95 % CI 0·36, 0·83; Ptrend=0·010) and lower plasma glucose levels. In addition, dietary protein and carbohydrate intake significantly contributed to the associations between dietary patterns and GDM risk or glucose levels. These findings suggest that a dietary pattern characterised by high protein and low carbohydrate intake in pregnancy was associated with a higher risk of GDM, which may provide important clues for dietary guidance during pregnancy to prevent GDM.