Researchers discovered that people with migraines harbour significantly more nitrate microbes in their mouth and guts in comparison to people who do not get the searing headaches.
Nitrates, found in processed meats, leafy green vegetables and certain medicines, help alleviate heart failure and chest pain, but for some too much bacteria will lead to migraines.
One in seven Brits suffer from 190,000 migraines every day, but researchers have urged sufferers that if they suspect nitrates are causing migraines then foods rich in the chemical should be avoided.
Lead author of the study Antonio Gonzalez (doub corr) said: “There is this idea out there that certain foods trigger migraines - chocolate, wine and especially foods containing nitrates.
“We thought perhaps there was a connection between someone’s microbiome and what they are eating.”
Mr Gonzalez and colleague Embriette Hyde from San Diego School of Medicine analysed data from the American Gut Project.
They examined 172 oral samples and 1,996 faecal samples from healthy participants, some of whom suffered from migraines.
Using a specialist tool the team found that migraine sufferers have a significant increase in the genes nitrate, nitrite and nitric oxide reductases.
Miss Hyde said: “We know for a fact the nitrate-reducing bacteria are found in the oral cavity.
“We definitely think this pathway is advantageous to cardiovascular health, but now we have a potential connection to migraines as well.”
Roughly 80 per cent of cardiac patients who take nitrate based drugs for chest pain or congestive heart failure suffer from severe headaches as a side effect.
Mr Gonzalez and his team say they hope to one day have a “magical mouthwash to help cardiovascular health” and say they hope their findings will spur more research to understand which microorganisms are related to migraines.
He said: “We will have a magical probiotic mouthwash for everyone that helps your cardiovascular health without giving you migraines.
“If you suspect that nitrates are causing you migraines you should try to avoid them in your diet.”
The report was published in the journal MSystems.