The aim of this study was to investigate the association between the adherence to empirically derived dietary patterns and gestational diabetes mellitus (GDM) risk and of healthy lifestyles with the prevention of GDM defining an overall healthy score. The Seguimiento Universidad de Navarra project is a Mediterranean cohort of university graduates started in 1999. We included 3455 pregnant women. During a mean follow-up of 10·3 (sd 3·3) years, we identified 173 incident GDM cases. Two major dietary patterns were identified using principal component analysis: the Western dietary pattern (WDP) (characterised by a high consumption of meat-based products and processed foods) and the Mediterranean dietary pattern (MDP) (characterised by a high consumption of vegetables, fruits, fish and non-processed foods). A low-risk score for GDM was defined taking into account important risk factors (age, BMI and unhealthy dietary pattern) for GDM. Positive association was found in the multivariable model between the highest quartile of adherence to WDP and GDM incidence compared with the lowest quartile (OR 1·56; 95 % CI 1·00, 2·43). No association was found between adherence to the MDP and GDM incidence (OR 1·08; 95 % CI 0·68, 1·70 for the highest quartile compared with the lowest). Women who adhered to all three low-risk factors had a 76 % lower risk of GDM (OR 0·24; 95 % CI 0·10, 0·55) compared with women who did not adhere to any factor before pregnancy. In conclusion, our results reinforce the importance of dietary recommendations and other two factors (low BMI and young age at pregnancy) in pre-gravid women.