Do you get headaches all the time? As if that weren't bad enough, you may be at increased risk for hypothyroidism—a common medical problem that can cause mood swings and weight gain, among other seriously unpleasant symptoms.

Previous research has suggested a link between the two conditions, and now, one of the largest and longest studies to date provides the strongest evidence yet. University of Cincinnati researchers found that people with headache disorders were 21% more likely to be diagnosed with hypothyroidism, compared to those without.

The group included anyone who’d been diagnosed with migraines, cluster headaches, or tension headaches, or who reported taking headache-specific medicine. Among migraine sufferers specifically, the increased risk jumped to 41%.

Hypothyroidism occurs when the body can’t make enough thyroid hormone to function properly. It can affect mood, weight, energy levels, concentration, and women’s menstrual cycles, and can even cause constipation and hair loss. The condition is estimated to affect about 2% of people, and women are five to eight times more likely to be diagnosed than men.

RELATED: 19 Signs Your Thyroid Isn't Working Right

To investigate the suspected link between headaches and thyroid disorders, researchers looked at data from 8,412 people who were interviewed and followed for an average of 12 years. The results were published this week in the online edition of Headache: The Journal of Head and Face Pain.

The study’s implications may apply most to people who get headaches regularly, says co-author Vincent Martin, MD, co-director of the Headache and Facial Pain Center at the UC Gardner Neuroscience Institute, because a large percentage of study participants with headache disorders stated on a questionnaire that their headaches were “frequent.”

There are several reasons why headache disorders may be a risk factor for thyroid problems, Dr. Martin says. One possibility is that an overactive immune system—triggered by recurrent headaches—makes the body more vulnerable to thyroid disease. Inflammation also seems to be involved in both conditions.

“No one knows for sure why there’s an association,” he adds. “It could even be a product of some of the medications people take to prevent their headaches; we just don’t know yet.” Environmental or genetic factors could play a role as well.

RELATED: 11 Surprising Migraine Triggers

It’s also possible that the development of a thyroid disorder, and subsequent low thyroid hormone levels, can make headaches worse and more frequent, Dr. Martin says.

In addition to headache disorders, people were more likely to receive a hypothyroidism diagnosis if they were female, older, obese, or taking certain medications, such as lithium, interferon, and amiodarone. Cigarette smoking actually seemed to have a protective effect—although no doctors would recommend this as a preventive measure, says Dr. Martin, as its risks greatly outweigh its benefits.

The good news? The symptoms of hypothyroidism can be well managed with replacement hormones, usually taken as a daily pill. “The silver lining here is that if you are diagnosed with thyroid disease, it can be easily treated—and if it is treated, your headaches or your migraines might actually improve.”

RELATED: The Best and Worst Foods for Your Thyroid

Dr. Martin encourages physicians to be vigilant in screening people with known headache disorders for hypothyroidism, and says anyone with regular headaches should be aware of their increased risk, too. 

“When you have migraines or bad headaches, you can feel fatigued, you don’t think quite as well, you can have a lot of symptoms that can resemble hypothyroidism,” he says. “Some people might be attributing those symptoms to their headaches or to the treatments for them, when in reality they have an underlying—and treatable—thyroid disorder.”