(CNN) When heartburn or ulcer pain strikes, drugs can target stomach acid to calm bellies and offer relief. But a new study suggests the medications may come with a hive-inducing side effect: allergies.

After analyzing health insurance data from more than 8 million people in Austria, researchers found that prescriptions of anti-allergy medications surged in those who were prescribed stomach acid inhibitors, a class of drugs that includes proton-pump inhibitors and H2 blockers.

The findings, published Tuesday in the medical journal Nature Communications, suggest that disrupting the stomach's delicate balance of acids and enzymes may cause our immune systems to go haywire, triggering allergies that didn't previously exist.

"We need to have the general awareness that the stomach has an important digestive function, and it has a kind of sterilizing function," said Dr. Erika Jensen-Jarolim, the study's lead author and a professor at the Medical University of Vienna.

"What we get in terms of food and bacteria is actually denatured and degraded in normal stomach function," she told CNN. "When you take anti-acids, this function is impaired, and we have a wide-open window, and many things enter the intestines that are not good."

It's not entirely understood how the medications contribute to allergies, but one explanation may be that reduced stomach acid allows undigested food to sneak out of our stomachs. Our immune systems, in turn, can see those foods as a threat.

"Food allergens are large proteins, they're part of large complexes, and we know that when anything we eat hits the stomach, it gets degraded," said Dr. Caroline Sokol, a physician and researcher at Massachusetts General Hospital who was not involved in the study.

"If you do not have any acid," she said, "you can imagine you've got these big chunks of protein that might get through a leaky gut wall. If you're showing your immune system these whole proteins that it can't usually see, then you're at a higher risk of potentially developing an immune response against them."

Gastric acid inhibitors may also induce an "allergic bias" in patients toward seasonal troublemakers like grass pollen, Jensen-Jarolim said. "There is evidence that anti-acid drugs don't just act on the digestive system, but they also act on immune cells, causing a release of pro-allergic substances."

'Luxury mice' offered first clues

While "there is still lots to do in the future" to understand the link between acid-targeting drugs and allergies, Jensen-Jarolim says she's studied the connection for years.

She got her first lead around two decades ago: a middle-aged man who said he started wheezing after eating caviar for the second time, with swelling in his mouth and throat as his blood pressure dropped.

The case was striking because allergies to caviar -- the small, pearly black fish eggs that regularly cost more than $100 per ounce -- are thought to be incredibly rare. Scientists have identified only a handful of cases to date.

"It was an interesting case because we, or at least some people, still know exactly when we eat caviar. And our patient knew that he ate caviar for the first time seven years before the (allergic reaction). So, he ate it twice, and he knew that in both instances he was on anti-acid treatment."

That suggested the man had become sensitized to caviar the first time he ate it, with too little acid in his stomach to break down the food, Jensen-Jarolim said. "So, that was a model case," she added, "because for other foods, it's not so easy to single out the co-factors that occur."

Her research team then fed both caviar and anti-acid medications to what Jensen-Jarolim jokingly called "luxury mice" and found that they, too, developed allergies. Looking at millions of people, the new research showed the same trend with more common allergens.

"This recent study cannot be neglected by the community," Jensen-Jarolim said. "We have the problem that gastroenterologists will say, well, we prescribe these drugs so much and nothing has happened yet." But allergies can happen years down the line, Jensen-Jarolim said, and "I hope they make the connection now."

'An allergy epidemic'

"We do not know why we have such an allergy epidemic," she said, "but clearly that is happening, and there are probably a lot of reasons why." Gastric acid inhibitors "could potentially be one of those reasons," she said.

"If you have severe acid reflux, then this is a perfectly fine drug. The risk-benefit analysis is clearly in favor of taking the drugs," Sokol emphasized.

"But we really have to think about the use of chronic medications that people stay on forever," she said, "especially in children where we really could be looking at promoting food allergies that could stay with them for life."

Get CNN Health's weekly newsletter Sign up here to get The Results Are In with Dr. Sanjay Gupta every Tuesday from the CNN Health team.

While those allergies can be uncomfortable and even life-threatening, there are other reasons to consider putting down gastric acid inhibitors. The drugs have been linked to an increased risk of stroke kidney failure and even early death

"We all assume that because something's available over the counter, that it doesn't have risks," Sokol said. "But clearly, every medication that we put into our body has risks."