About four in every ten people who abstain from food and water all day during the month-long Ramadan period get headaches, said the study, published in the journal Headache. This year, Ramadan began on August 1.
"Religious fasting is associated with headache," wrote lead researcher Michael Drescher, from Hartford Hospital in Connecticut, the United States, referring to Ramadan and Judaism's Yom Kippur, when people fast for 25 hours.
"This has been documented as the 'Yom Kippur headache' and 'first of Ramadan headache.'"
Doctors aren't quite sure what causes them. It could be dehydration, or caffeine withdrawal in people who are used to getting their morning coffee, Drescher told Reuters Health.
"There's probably more than one thing going on," he added.
Drescher and his Israel-based colleagues had already shown that Jews who took the drug known as etoricoxib, or Arcoxia, before fasting for 25 hours on the Yom Kippur holiday got fewer headaches than those who didn't.
Arcoxia, a cousin of the painkiller Vioxx, isn't approved for use in the United States because the Food and Drug Administration decided it was too similar to Vioxx, which Merck pulled from the market in 2004 when it was linked to a higher risk of heart attack. But Arcoxia is available in Israel, among other countries.
The drug has a longer-lasting effect than some other painkillers, which is important because taking a pill in the middle of the day when a headache sets in would be considered breaking the fast.
"If you take Tylenol (acetaminophen)... by the time you get around to feeling the effects of the fast, the medicine is long out of your system," Drescher said.
To see how Arcoxia would work during Ramadan, the researchers assigned 222 adults planning to fast in 2010 to either take the drug or an inactive placebo pill just before the start of fasting each day. All participants recorded how often they had a headache, and how severe it was.
After a week they switched treatments.
During the first day of fasting, when headaches are thought to be most common, 21 percent of people taking Arcoxia reported having a headache, compared to 46 percent of those who took the placebo pill.
The Arcoxia group also reported fewer total headaches during that first week, the researchers wrote. And when they did have headaches, they rated them as less severe than participants taking the placebo.
After a week, there was no longer any difference in symptoms between the groups, partly because even the people taking the placebo reported fewer headaches during fasting as time went on.
Drescher said this sort of finding had been noticed before.
"As to why exactly it happens, we don't know. Perhaps the body goes through some sort of desensitization to the fasting," he said.
He added that although the researchers didn't contact any Muslim religious authorities about the use of the drug during fasting, none of the participants voiced any objection to it.
When the researchers previously talked to rabbis about use of Arcoxia during Yom Kippur, the Jewish leaders pointed out that not having a headache could allow people to be "freer spiritually."
"The religious edict to fast really is not a command to suffer," Drescher added.
The study was funded by Merck, which makes the drug, and two of the study's six authors are company employees.