Researchers at Johns Hopkins University analysed data from 3,400 men aged 20 and older who took part in the national Health and Nutrition Examination Survey.
They found that men were more likely to suffer from ED if they suffered from vitamin D deficiency when compared to men who got the recommended amount of the "sunshine vitamin" each day.
"Checking vitamin D levels may turn out to be a useful tool to gauge ED risk," lead investigator Erin Michos commented on the study.
The study found that vitamin D deficiency - defined as vitamin D levels below 20 nanograms per millilitre of blood - was present in 35% of men with ED, compared with 29% of men without ED.
After the researchers took other factors known to lead to impotence into account - including certain medications, alcohol use, smoking, diabetes, inflammation and high blood pressure - they estimated that men who suffer from vitamin D deficiency are 32% more likely to have ED than men with adequate vitamin D levels.
According to the Johns Hopkins University report, risk factors for vitamin D deficiency include being obese or overweight, undergoing limited outdoor activity, having darker skin and suffering from certain from inflammatory conditions, such as diabetes and inflammatory bowel disease.
The good news is that ED can be fairly simple to treat if vitamin D deficiency is the root cause.
The study reads: "Vitamin D deficiency is easy to screen for and simple to correct with lifestyle changes that include exercise, dietary changes, vitamin supplementation and modest sunlight exposure."
It's worth noting though that vitamin D deficiency may not be the only thing causing your ED.
Other underlying causes can include hormonal problems, high cholesterol, diabetes, relationship problems, anxiety and depression, so it's important to visit your GP if you're suffering.
Also on HuffPost: