Having sex may be the solution to curing a splitting headache.

Researchers from the University of Munster in Germany have found that sexual activity was successful in treating migraines in 60 percent sufferers and in one-third of patients with cluster headaches.

"Our data suggest...that sexual activity can lead to partial or complete relief of headache in some migraine and a few cluster headache patients," wrote the authors of the study, published Feb. 19 in Cephalagia.

Get Breaking News Delivered to Your Inbox

"Our results show that sexual activity during a migraine attack might relieve or even stop an attack in some cases, and that sexual activity in the presence of headache is not an unusual behavior," they added.

Migraines are a kind of throbbing headache that may cause nausea, vomiting or sensitivity to light. Some people get a warning symptom like vision disturbances called an aura before the headache hits. Migraines occur more often in women than men and may run in families. Some women say they have less migraines when they are pregnant.

Cluster headaches differ from migraines, and are characterized by chronic, one-sided headaches that can include eye tearing, steady burning and sharp sensations, and stuffy noses. They can occur regularly during one week to one year, and may be spaced out by attack-free periods. A cluster headache can begin as a severe, sudden headache often around the same time of the day you had the last one. They happen more often in men than women and may run in families.

The researchers looked at 800 patients with migraines and 200 patients with cluster headaches. Patients were asked to complete a questionnaire about their sexual activity during their headache episodes and write how sex affected the pain.

About one-third of the patients said they had sex during a migraine or a cluster headache. Sixty percent of migraine sufferers who had sex said they had some sort of pain relief, with most of them reporting moderate or complete alleviation of their symptoms. Some participants -- mostly men -- admitted to using sex as a way to treat the migraines. For one-third of the migraine patients who had sex, the pain got worse.

Thirty-seven percent of cluster headache patients said sex helped lessen the pain, with 90 percent of those patients who had sex saying they experienced moderate to complete relief of headaches. However, 50 percent of them said sex only made headaches worse.

Study researcher Stefan Evers, a neurologist and headache specialist at the University of Munster in Germany, told LiveScience that sex releases endorphins, which are natural painkillers. Other studies have shown that sex can alleviate migraines, but the studies were done on a smaller scale. Evers suggested that masturbation or any sexual activity may be able to get rid of headaches in some people.

"Having an orgasm in any way shape or form will help (them)," he said.