It is likely that the Mediterranean diet (MedDiet) may mitigate the adverse effects of obesity on the incidence of type 2 diabetes mellitus (T2DM). We assessed this hypothesis in a cohort of 18 225 participants initially free of diabetes (mean age: 38 years, 61 % women). A validated semi-quantitative 136-item FFQ was used to assess dietary intake and to build a 0–9 score of adherence to MedDiet. After a median of 9·5-year follow-up, 136 incident cases of T2DM were confirmed during 173 591 person-years follow-up. When MedDiet adherence was low (≤4 points), the multivariable-adjusted hazard ratios (HR) were 4·07 (95 % CI 1·58, 10·50) for participants with BMI 25–29·99 kg/m2 and 17·70 (95 % CI 6·29, 49·78) kg/m2 for participants with BMI≥30 kg/m2, (v.<25 kg/m2). In the group with better adherence to the MedDiet (>4 points), these multivariable-adjusted HR were 3·13 (95 % CI 1·63, 6·01) and 10·70 (95 % CI 4·98, 22·99) for BMI 25–30 and ≥30 kg/m2, respectively. The P value for the interaction was statistically significant (P=0·002). When we assessed both variables (BMI and MedDiet) as continuous, the P value for their interaction product-term was marginally significant (P=0·051) in fully adjusted models. This effect modification was not explained by weight changes during follow-up. Our results suggest that the MedDiet may attenuate the adverse effects of obesity on the risk of T2DM.