Carbohydrate quantity and quality affect postprandial glucose response, glucose metabolism and risk of type 2 diabetes. The aim of this study was to examine the association of pre-pregnancy dietary carbohydrate quantity and quality with the risk of developing gestational diabetes mellitus (GDM). We used data from the Australian Longitudinal Study on Women’s Health that included 3607 women aged 25–30 years without diabetes who were followed up between 2003 and 2015. We examined carbohydrate quantity (total carbohydrate intake and a low-carbohydrate diet (LCD) score) and carbohydrate subtypes indicating quality (fibre, total sugar intake, glycaemic index, glycaemic load and intake of carbohydrate-rich food groups). Relative risks (RR) for development of GDM were estimated using multivariable regression models with generalised estimating equations. During 12 years of follow-up, 285 cases of GDM were documented in 6263 pregnancies (4·6 %). The LCD score, reflecting relatively high fat and protein intake and low carbohydrate intake, was positively associated with GDM risk (RR 1·54; 95 % CI 1·10, 2·15), highest quartile v. lowest quartile). Women in the quartile with highest fibre intake had a 33 % lower risk of GDM (RR 0·67; 95 % CI 0·45, 0·96)). Higher intakes of fruit (0·95 per 50 g/d; 95 % CI 0·90, 0·99) and fruit juice (0·89 per 100 g/d; 95 % CI 0·80, 1·00)) were inversely associated with GDM, whereas cereal intake was associated with a higher risk of GDM (RR 1·05 per 20 g/d; 95 % CI 1·01, 1·07)). Thus, a relatively low carbohydrate and high fat and protein intake may increase the risk of GDM, whereas higher fibre intake could decrease the risk of GDM. It is especially important to take the source of carbohydrates into account.