Drinking three or more cups of coffee in a day can trigger migraine, warns new research.

The study linked a high daily intake of drinks containing caffeine with the onset of debilitating migraine headaches on the same or next day.

The findings, published in The American Journal of Medicine, show that supping three or more servings of caffeinated drinks a day is associated with the onset of a headache by the following day in patients with episodic migraine.

Researchers said that their results were consistent even after accounting for daily changes in alcohol intake, stress, sleep, physical activity, and menstruation, although there was some variation evident with oral contraception use.

Lead investigator Elizabeth Mostofsky, of Harvard T.H. Chan School of Public Health in the US, said: "Based on our study, drinking one or two caffeinated beverages in a day does not appear to be linked to developing a migraine headache, however, three or more servings may be associated with a higher odds of developing a headache."

Migraine affects more than one billion adults worldwide and is the most common pain condition causing lost productivity and significant direct and indirect costs.

But, despite widespread anecdotal belief that drinks containing caffeine may trigger migraine and relieve headaches once they have begun, there was limited scientific evidence to assess the potential association.

The research team said that common anecdotal evidence also suggested that migraine can be immediately triggered by weather or lifestyle factors, such as sleep disturbance or skipping meals.

They analysed figures from 98 adults who suffer from migraine. The participants completed electronic diaries twice a day for six weeks reporting on their caffeinated drink intake, other lifestyle factors, and the timing and characteristics of each migraine headache.

The study compared each participant's incidence of migraines on days they consumed caffeinated drinks to the incidence of migraines on days they did not.

Initial figures had indicated that the participants typically experienced an average of five headaches per month; 66 per cent of them usually drank one to two servings of caffeinated daily daily, while 12 per cent drank three or more cups.

During the six-week study period in 2016-17, participants experienced an average of 8.4 headaches. All of them said they had a caffeinated drink on at least one day during the study, with an average of 7.9 servings per week.

Study principal investigator Dr Suzanne Bertisch, of Harvard Medical School, said: "To date, there have been few prospective studies on the immediate risk of migraine headaches with daily changes in caffeinated beverage intake.

"Our study was unique in that we captured detailed daily information on caffeine, headache, and other factors of interest for six weeks."

She said the findings suggest that the impact of caffeinated drinks on headache risk was only apparent for three or more servings on that day, and that patients with episodic migraine did not experience a higher risk of migraine when consuming one or two caffeinated drinks per day.

Dr Bertisch added: "Additional research is needed to examine the potential effect of caffeine on symptom onset in the subsequent hours and the interplay of sleep, caffeine, anxiety, environmental factors, and migraine."