A drug that has been used for decades to treat allergic asthma and hives significantly reduced the risk of life-threatening reactions in children with severe food allergies who were exposed to trace amounts of peanuts, cashews, milk and eggs, researchers reported on Sunday.

The drug, Xolair, has already been approved by the Food and Drug Administration for adults and children over age 1 with food allergies. It is the first treatment that drastically cuts the risk of serious reactions — like anaphylaxis, a life-threatening allergic reaction that causes the body to go into shock — after accidental exposures to various food allergens.

The results of the researchers’ study on children and adolescents, presented at the annual conference of the American Academy of Allergy, Asthma and Immunology in Washington, were published in The New England Journal of Medicine.

“For a certain population of food allergy patients, this medication will be life-changing,” said Dr. Robert A. Wood, the paper’s first author and director of the Eudowood Division of Pediatric Allergy, Immunology and Rheumatology at Johns Hopkins Children’s Center.

“If you have a severe milk or egg allergy, or something that was not even part of this study — like garlic or mustard — you cannot eat in a restaurant, ever,” Dr. Wood said.

“There is also the fear and anxiety that you walk around with every day,” he added. “I have many patients who are teenagers, and they have never been allowed to eat in a restaurant. The family has never gotten on an airplane because of the fear of the allergy.”

Food allergies have been increasing in prevalence over the past 20 years, though it is not clear why. Some 5.5 million children and 13.6 million U.S. adults have food allergies, and many are allergic to more than one food.

Nearly half of people with food allergies have experienced a severe, life-threatening reaction. Food allergies are the cause of an estimated 30,000 emergency department visits a year.

Dr. Ann Marqueling and Dr. Kevin Wang, in Palo Alto, Calif., have a 5-year-old son, Liam, with multiple food allergies who participated in the trial.

They have not been told whether their son was randomized to receive the drug or dummy injections. But by the end of the treatment phase, he showed more tolerance to trace amounts of eggs, peanuts and tree nuts, they said. They believe he was given Xolair.

“It’s been very liberating for us, but it’s also liberating for him — we don’t watch him like a hawk everywhere for the accidental exposures,” Dr. Wang said. “We’re still watchful, but not hovering. Instead of us being on red alert, it’s a yellow or orange alert.”

“We’ve felt more comfortable letting him run around and explore,” Dr. Marqueling said. “We’re letting him be a kid.”

But while some hailed Xolair’s approval as a breakthrough, experts cautioned that it was far from a perfect solution. The drug lowers the risk of a reaction to trace amounts of an allergen, but life-threatening episodes are still possible. Patients still must scrupulously avoid foods likely to trigger a reaction.

The drug is not easy to take, administered by injection every two to four weeks. Many people, especially children, don’t like shots and fear needles. And in order for Xolair to be effective, patients must take it regularly.

Only one other drug, Palforzia, is approved for reducing severe reactions, but it is only for those with peanut allergies. It is an oral immunotherapy regimen that works by gradually exposing children to small amounts of peanut protein until they can safely eat the equivalent of two peanuts. Those taking Palforzia must also continue to avoid peanuts.

The study of Xolair, funded in large part by the National Institute of Allergy and Infectious Diseases, was of the kind considered the gold standard in medicine: a double-blind, randomized, placebo-controlled clinical trial.

It was carried out at 10 medical centers across the United States and included 177 children and adolescents aged 1 to 17, all of whom were allergic to peanuts and at least two other foods including cashew, milk, egg, walnut, wheat and hazelnut.

To be included, they had to have an allergic reaction to 100 milligrams or less of peanut protein (less than half a peanut) and to 300 milligrams or less of two other foods from a list that included milk and eggs, among others.

The participants were randomly assigned to receive injections of Xolair or a placebo every two to four weeks for 16 to 20 weeks. (The frequency of dosing was based on individual characteristics, including weight.)

After the treatment phase was complete, the participants were tested to see if they could tolerate trace amounts of food allergens. Of the 118 participants who received the drug, 79, or 67 percent, were able to tolerate up to 600 milligrams of peanut protein in a single dose — equivalent to just over half a teaspoon of peanut butter, or about two and a half peanuts — without serious symptoms.

Only four of 59 participants given the placebo injections, or 7 percent, were able to do so.

Levels of protection varied by food: 41 percent of those allergic to cashews who received the drug did not have reactions when they ate up to 1,000 milligrams of cashews, for example, compared with 3 percent of those in the placebo comparison group.

Two-thirds of those with allergies to milk who took the drug were able to tolerate up to 1,000 milligrams of milk protein, compared with 10 percent who were in the placebo group.

More than two-thirds of those with egg allergies tolerated up to 1,000 milligrams of egg protein if they had been given the drug, while no one in the placebo group could. All of the findings were statistically significant.

Xolair is a man-made antibody directed at immunoglobulin E (IgE), which is produced by the body’s immune system and drives allergic reactions.

The drug binds to IgE, acting “like a sponge that soaks it all up,” said Dr. Sharon Chinthrajah, the paper’s senior author and acting director of the Sean N. Parker Center for Allergy and Asthma Research at Stanford University.

Even though the drug has been approved for other uses for two decades, Genentech did not study whether Xolair could be beneficial against severe food allergies until the National Institute of Allergy and Infectious Diseases’s Consortium for Food Allergy Research, which provided funding, approached the company in 2017, an institute spokeswoman said.

Dr. Larry Tsai, global head of respiratory, allergy and infectious disease product development at Genentech, which developed Xolair with Novartis, emphasized that the drug was not intended to cure allergies and does not do so.

But, he added, it can be helpful to someone like his own college-bound daughter, who has multiple food allergies and worries about accidental exposures in a cafeteria or restaurant.

“My daughter can easily avoid eating a lobster or a handful of peanuts,” Dr. Tsai said. “What’s more worrisome is if she goes out to lunch with friends and eats a sandwich that happened to have been cut with a knife that had been used previously to spread peanut butter and wasn’t washed thoroughly — and she ends up in a hospital. That’s a fear patients live with.”