The dietary inflammatory index (DII) is a new tool to assess the inflammatory potential of the diet. In the present study, we aimed to determine the association between the DII and BMI, waist circumference and waist:height ratio (WHtR). We conducted a cross-sectional study of 7236 participants recruited into the PREvencion con DIeta MEDiterranea trial. Information from a validated 137-item FFQ was used to calculate energy, food and nutrient intakes. A fourteen-item dietary screener was used to assess adherence to the Mediterranean diet (MeDiet). Sex-specific multivariable linear regression models were fitted to estimate differences (and 95% CI) in BMI, waist circumference and WHtR across the quintiles of the DII. All nutrient intakes, healthy foods and adherence to the MeDiet were higher in the quintile with the lowest DII score (more anti-inflammatory values) except for intakes of animal protein, saturated fat and monounsaturated fat. Although an inverse association between the DII and total energy was apparent, the DII was associated with higher average BMI, waist circumference and WHtR after adjusting for known risk factors. The adjusted difference in the WHtR for women and men between the highest and lowest quintiles of the DII was 1·60% (95% CI 0·87, 2·33) and 1·04% (95% CI 0·35, 1·74), respectively. Pro-inflammatory scores remained associated with obesity after controlling for the effect that adherence to a MeDiet had on inflammation. In conclusion, the present study shows a direct association between the DII and indices of obesity, and supports the hypothesis that diet may have a role in the development of obesity through inflammatory modulation mechanisms.