Abstract Pro-inflammatory diets are associated with cognitive decline and dementia, but their impact on brain aging is unclear. We investigated the association between a pro-inflammatory diet and brain age, taking into account age, genetic risk for dementia, and systemic inflammation. UK Biobank participants (N = 21,473) aged 40–70 years and free of neurological disorders were included. The Dietary Inflammatory Index (DII) was calculated from participants’ average intake of 31 nutrients, assessed up to five times via 24-h recalls. Participants were categorized into four DII groups (group 1, anti-inflammatory, DII < −2; group 2, DII −2 to < 0; group 3, DII 0 to < 2; group 4, DII ≥ 2), with group 4 reflecting the most pro-inflammatory diet. Brain age was estimated using a machine learning model based on 1079 structural and functional MRI measures, obtained approximately 9 years after baseline. We calculated brain age gap (BAG; brain age minus chronological age), where BAG > 0 reflects a biologically older brain than chronological age. An Alzheimer’s disease polygenic risk score (PRS AD ), APOE 4 status, and a composite score of systemic inflammation (INFLA-score) were determined from baseline blood samples. More pro-inflammatory diets were associated with increasingly greater BAG, with advanced brain age by $$\widehat{\upbeta }$$ =0.50 [95% CI 0.20, 0.80] years among those in group 4. There were no interactions between DII and age, PRS AD , or APOE 4 in relation to BAG, but associations were stronger among adults ≥ 60 years. INFLA-score mediated 8% of the DII-BAG association. These findings suggest that a pro-inflammatory diet may accelerate brain aging, especially in older adults.