The Mediterranean diet, which has been recommended for heart disease sufferers , may have an additional benefit if your family is genetically predisposed to suffering from strokes.
People with two copies of a specific gene variant were less likely to suffer a stroke if they ate a diet mainly consisting of olive oil, fresh fruits and vegetables, nuts and fish.
Their stroke susceptibility became the same as that of individuals with no copies of the mutation, or just one.
The Stroke Association estimates around 150,000 people in Britain suffer from strokes each year, and although most are over 65, they can happen at any age from babies upwards.
WHAT IS A STROKE?
For your brain to function, it needs a constant blood supply, which provides vital nutrients and oxygen to the brain cells. A stroke happens when the blood supply to part of the brain is cut off and brain cells are damaged or die.
About a third of people who have a stroke make a significant recovery within a month. But most stroke survivors will have long-term problems. It may take a year or longer for them to make the best possible recovery.
Source: Stroke Association
The Cleveland Clinic in the US advises that to reduce the risk of a stroke, cutting back on alcohol, salt and sugar and maintaining your weight is key.
The TCF7L2 gene has previously been strongly linked to type 2 diabetes but not heart and artery disease.
Scientists studied more than 7,000 Spanish men and women who ate either a Mediterranean or normal low-fat diet for almost five years.
Story continues below the slideshow:
Around 14% of participants carried two copies of the gene variant associated with diabetes.
"Being on the Mediterranean diet reduced the number of strokes in people with two copies of the variant," said study leader Professor Jose Ordovas, from Tufts University in the US .
"The food they ate appeared to eliminate any increased stroke susceptibility, putting them on an even playing field with people with one or no copies of the variant.
"The results were quite different in the control group following the low-fat diet, where homozygous carriers (with two gene copies) were almost three times as likely to have a stroke compared to people with one or no copies of the gene variant."
The research is reported online in the journal Diabetes Care.
More work is need to uncover the mechanism behind the interaction between diet and genetic make-up, said the scientists.
The TCF7L2 gene has previously been implicated in glucose metabolism and the variant observed in the study is strongly linked to the development of type 2 diabetes.