As well as nine tablespoons of olive oil, they found men tended to be protected if their diet also contained about 13 portions of veg a week, six pieces of fruit, three servings of fish and two portions of beans.
The scientists believe this diet helps men maintain a healthy heart and clear blood vessels, which results in a good flow of blood to the groin.
The cardiologists also found men who followed this diet had higher testosterone levels because they had lower levels of body fat – which can interfere with hormones.
Study leader Dr Christina Chrysohoou said: "Viagra does not improve something long-term, it can only give some short effect in order to have sexual capacity.
"This is a drug-free solution that allows men to keep their sexual function."
Just 20 per cent of the men she studied had erectile dysfunction – well below the 52 per cent expected in that age group.
The diet has a positive impact on the health of the aorta, a large artery which distributes blood from the heart to the rest of the body, she added.
But Professor Mike Wyllie, one of the scientists who developed Viagra, believes men "just want to take a pill" and "can't be bothered to change their lifestyle".
Julie Ward, of the British Heart Foundation, said: "It's no surprise the Mediterranean diet, which we know is beneficial to heart and circulatory health, might also benefit blood vessels elsewhere, and help men maintain healthy sexual function."
Erectile dysfunction affects 52 per cent of men aged between 40 and 70.
Medical firms have long sought out ways to treat the problem – knowing an effective treatment could generate a fortune.
Viagra sales soared earlier this year when restrictions were lifted to make them available over the counterin the UK – rising 60 per cent in the first three months after the rule change in March.
But not all men respond to the drug, and many others dislike having to take a pill during romantic moments.
Dr Chrysohoou said just 20 per cent of the men she studied had erectile dysfunction - well below the 52 per cent expected in that age group.
And those who had the diet closest to the Mediterranean ideal were protected even further.
She said the key lies in the health of the aorta - a large artery which distributes blood from the heart to the rest of the body.
"What we found here is that the Med diet has a positive effect on aortic dilatation," she said.
"It keeps your blood vessels healthy and helps men maintain sexual function.
"And of all of the components of the Med diet, it is the olive oil that has a specific effect on aortic dilatation and sexual function as well."
How to follow a Mediterranean diet
Consuming more fruit and fish, and fewer sugary drinks and snacks, are the most important aspects of a Mediterranean diet.
• Emphasis on:
Fruits, vegetables, legumes, nuts, seeds, whole grains, fiish and meat, monounsaturated fats, such as olive oil
• Eat less:
Saturated fats, like butter, red meat, processed foods, like juice and white bread, soda, sugar
• Eat in moderation:
A glass of red wine here and there is fine
• How you can follow it:
Eat more fish, wqueeze more fruit and veg into every meal, swap your sunflower oil or butter for extra virgin olive oil, snack on nuts, eat fruit for dessert