OBJECTIVE: High BMI at midlife is associated with increased risk of dementia as well as faster decline in cognitive function. In late-life, however, high BMI has been found to be associated with both increased and decreased dementia risk. The objective of this study was to investigate the neural substrates of this age-related change in body mass index (BMI) risk. METHODS: We measured longitudinal cortical thinning over the whole brain, based on magnetic resonance imaging scans for 910 individuals aged 44-66 years at baseline. Subjects were sampled from a large population study (PATH, Personality and Total Health through Life). After attrition and exclusions, the final analysis was based on 792 individuals, including 387 individuals aged 60-66 years and 405 individuals aged 44-49 years. A mixed-effects model was used to test the association between cortical thinning and baseline BMI, as well as percentage change in BMI. RESULTS: Increasing BMI was associated with increased cortical thinning in posterior cingulate at midlife (0.014 mm kg(-1) m(-2), confidence interval; CI = 0.005, 0.023, P < 0.05 false discovery rate (FDR) corrected). In late-life, increasing BMI was associated with reduced cortical thickness, most prominently in the right supramarginal cortex (0.010 mm kg(-1) m(-2), CI = 0.005-0.016, P < 0.05 FDR corrected), as well as frontal regions. In late-life, decreasing BMI was also associated with increased cortical thinning, including right caudal middle frontal cortex (0.014 mm kg(-1) m(-2) (CI = 0.006-0.023, P < 0.05 FDR corrected). CONCLUSIONS: The pattern of cortical thinning-in association with increasing BMI at both midlife and late-life-is consistent with known obesity-related dementia risk. Increased cortical thinning in association with decreasing BMI at late-life may help explain the 'obesity paradox', where high BMI in midlife appears to be a risk factor for dementia, but high BMI in late-life appears, at times, to be protective.