Aim: The impact of the anti-inflammatory potential of diet on risk of heart failure (HF) and the potential modification of this association by smoking, a trigger of systemic inflammation, has not been previously investigated. We examined the association between anti-inflammatory potential of diet and risk of HF taking into account smoking status. Methods and results: The study population included the Cohort of Swedish Men (40 514 men) and the Swedish Mammography Cohort (34 809 women), age 45–83 years, without HF, ischaemic heart disease, or cancer at baseline. Anti-inflammatory potential of diet was estimated using an anti-inflammatory diet index (AIDI; 0–16 scores). Cox proportional hazard regression models were used to estimate hazard ratios (HRs) with 95% confidence intervals (CIs) adjusted for HF risk factors. Over a mean follow-up of 14.9 years (1 119 110 person-years, 1998–2014), 8161 new HF diagnoses (4443 in men, 3718 in women) were identified. Compared to the lowest quintile of the AIDI (scores ≤4), the HRs for men and women in the highest quintile (scores ≥8) were 0.92 (95% CI 0.84–1.02; P-trend = 0.02) and 0.86 (95% CI 0.78–0.96; P-trend = 0.001), respectively. An inverse association between the AIDI and HF incidence was observed in current and ex-smokers but not in never-smokers (P-interaction = 0.046). Comparing extreme quintiles, the HRs were 0.86 (95% CI 0.74–1.00; P-trend = 0.007) in current smokers, 0.81 (95% CI 0.71–0.92; P-trend = 0.001) in ex-smokers, and 0.95 (95% CI 0.86–1.06; P-trend = 0.10) in never-smokers. Conclusion: These results suggest that adherence to a diet with high anti-inflammatory potential may be associated with lower HF incidence in current and ex-smokers.