To postpone cognitive decline and dementia in old age, primary prevention is required earlier in life during middle age. Dietary components may be modifiable determinants of mental performance. In the present study, habitual fruit and vegetable intake was studied in association with cognitive function and cognitive decline during middle age. In the Doetinchem Cohort Study, 2613 men and women aged 43-70 years at baseline (1995-2002) were examined for cognitive function twice, with a 5-year time interval. Global cognitive function and the domains memory, information processing speed and cognitive flexibility were assessed. Dietary intake was assessed with a semi-quantitative FFQ. In multivariate linear regression analyses, habitual fruit and vegetable intake was studied in association with baseline and change in cognitive function. Higher reported vegetable intake was associated with lower information processing speed (P = 0·02) and worse cognitive flexibility (P = 0·03) at baseline, but with smaller decline in information processing speed (P < 0·01) and global cognitive function (P = 0·02) at follow-up. Total intakes of fruits, legumes and juices were not associated with baseline or change in cognitive function. High intakes of some subgroups of fruits and vegetables (i.e. nuts, cabbage and root vegetables) were associated with better cognitive function at baseline and/or smaller decline in cognitive domains. In conclusion, total intake of fruits and vegetables was not or inconsistently associated with cognitive function and cognitive decline. A high habitual consumption of some specific fruits and vegetables may diminish age-related cognitive decline in middle-aged individuals. Further research is needed to verify these findings before recommendations can be made.