Those who teamed the foods with exercise were found to have an even lower chance of developing erectile dysfunction.
Erectile dysfunction (ED) is the inability to get and maintain an erection. It is a very common condition, particularly in older men, and it's estimated that half of all men between the ages of 40 and 70 will have it to some degree.
Participants were asked about their ability to have and maintain an erection sufficient for intercourse, as well as their dietary intake over the years.
Researchers took into account a range of factors including body weight, physical activity, amount of caffeine consumed and whether the participants smoked.
They found that those who consumed a diet rich in flavonoids were less likely to suffer from erectile dysfunction later in life. Additionally, researchers discovered that some flavonoid-filled foods were better at preventing the condition than others.
Foods found to have the greatest benefits were blueberries, cherries, blackberries, radishes and blackcurrant, which contain anthocyanins, as well as citrus fruits containing flavanones and flavones.
The benefits were strongest among younger men.
The study revealed that a higher total fruit intake was associated with a 14% reduction in the risk of erectile dysfunction.
Meanwhile a combination of consuming flavonoid-rich foods with exercise can reduce the risk by as much one fifth (21%).
"We already knew that intake of certain foods high in flavonoids may reduce the risk of conditions including diabetes and cardiovascular disease," said lead researcher Professor Aedin Cassidy from the University of East Anglia.
"This is the first study to look at the association between flavonoids and erectile dysfunction, which affects up to half of all middle-aged and older men."
"Flavonoids are present in many plant-based foods and drinks including fruits, vegetables, tea, herbs and wine," explained Professor Cassidy.
"We examined six main types of commonly consumed flavonoids and found that three in particular – anthocyanins, flavanones and flavones – are beneficial."
Men who consumed multiple portions of flavonoid-filled foods every week were 10% less likely to suffer from erectile dysfunction.
"The top sources of anthocyanins, flavones and flavanones are strawberries, blueberries, red wine, apples, pears, and citrus products," Professor Cassidy said.
Dr Eric Rimm, senior author and a Professor of Epidemiology and Nutrition at Harvard, said: "As well as improving sexual health for middle-aged men, there is another important benefit linked to heart health.
"Erectile dysfunction is often an early barometer of poor vascular function and offers a critical opportunity to intervene and prevent cardiovascular disease, heart attack and even death.
"Men with erectile dysfunction are likely to be highly motivated to make healthier lifestyle choices, such as exercising more and eating the right foods – which would greatly benefit their long-term cardiovascular health as well."
Dr Helen Webberley, the dedicated GP for Oxford Online Pharmacy, said the study had delivered "interesting findings".
"As with all medical remedies, people are always looking for 'natural' and 'herbal' remedies," she said.
"A lot of erectile dysfunction is associated with the failing smaller blood vessels, and anything that helps those will also be beneficial to the brain and heart.
"We need more studies to prove that these dietary modifications are going to be as effective as the current medications, but it goes without saying that we should not smoke, we should keep our weight healthy, exercise regularly and watch our risk factors such as high blood pressure, cholesterol and diabetes."
The research was published today in The American Journal of Clinical Nutrition.