A Mediterranean diet low in red meat and dairy food and high in omega-3 fatty acids can help preserve memory and thinking abilities, say researchers.
Scientists in the US studied the diets of 17,478 people with an average age of 64.
Participants were given tests that measured mental ability over an average of four years.
During the course of the study, 7% developed memory and thinking deficits.
The study found people who more closely followed a Mediterranean diet had a 19% reduced risk of mental impairment.
A key element of the Mediterranean diet is omega-3 fatty acids, found in oily fish, flax seed, walnuts and pulses, which are known to benefit the brain and nervous system.
The diet typically also contains high levels of fresh fruit and vegetables and low levels of saturated fat.
The findings are published in the latest issue of the journal Neurology.
Lead researcher Dr Georgios Tsivgoulis, from the universities of Alabama in the US and Athens in Greece, said: "Since there are no definitive treatments for most dementing illnesses, modifiable activities, such as diet, that may delay the onset of symptoms of dementia are very important.
"Diet is an important modifiable activity that could help in preserving cognitive functioning in late life. However, it is only one of several important lifestyle activities that might play a role in late-life mental functioning. Exercise, avoiding obesity, not smoking cigarettes and taking medications for conditions like diabetes and hypertension are also important."
Dr Simon Ridley, from the charity Alzheimer's Research UK, said: "The people in this study did not live in the Mediterranean, and we can't be certain from this study how close their eating habits were to a true Mediterranean diet.
"Although cognitive decline in later life can be a precursor to dementia, it's important to note that this study didn't look at dementia and it would be useful to see whether the people in this study went on to develop the condition. Ultimately long-term controlled trials will be needed to discover whether any particular diet can protect against cognitive decline."
Jessica Smith, from the Alzheimer's Society, said: "It's not just sun, sea and sand that make a Mediterranean lifestyle attractive. Studies have consistently shown that following a Mediterranean diet packed with olive oil, vegetables and chicken and low in saturated fats may help stave off memory problems in later life.
"Though there is currently no cure for dementia, this study shows that the choices we make about our lifestyle can have a big impact on our brain health. "