Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Want a healthy baby? You may want to roll her around in dirt.

For decades, parents have shielded infants from bacteria and other possible triggers for illness, allergies and asthma.

But a surprising new study suggests that exposure to cat dander, a wide variety of household bacteria — and even rodent and roach allergens — may help protect infants against future allergies and wheezing.

Interestingly, contact with bacteria and dander after age 1 was not protective — it actually increased the risk.

“It was the opposite of what we expected,” said Dr. Robert Wood, chief of the division of allergy and immunology at the Johns Hopkins Children’s Center and co-author of the study in the Journal of Allergy and Clinical Immunology. “We’re not promoting bringing rodents and cockroaches into the home, but this data does suggest that being too clean may not be good.”

The new findings may help explain some contradictions in research on the so-called hygiene hypothesis, which suggested that kids growing up in a super clean environment were more likely to develop allergies.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

“This doesn't completely resolve the controversy, but it does add a big piece of the puzzle,” said Dr. Jonathan Spergel, a professor of pediatrics and chief of allergy at the Children’s Hospital of Philadelphia.

The hygiene hypothesis was developed after researchers noticed that farm kids were less likely to have allergies. Dirty environments, experts suggested, might be protective. The hypothesis seemed to explain why developed countries had skyrocketing rates of allergies and asthma.

“We’re not promoting bringing rodents and cockroaches into the home, but this data does suggest that being too clean may not be good.”

The theory “is that as we clean up our environment, our immune system moves away from being geared toward fighting bacteria and parasites,” said Dr. Maria Garcia Lloret, an assistant clinical professor of pediatric allergy and immunology at the Mattel Children’s Hospital at the University of California, Los Angeles. “It then has nothing to do and starts to react against things that are normally not harmful, like dust mites, or cat dander or cockroaches or peanuts.”

A chink in the hygiene hypothesis seemed to be the high rates of allergy and asthma in inner-city environments. But the new study may help explain the contradictions by showing that early exposure is crucial.

“It’s all about being exposed to the right bacteria at the right time,” Spergel said.

Wood and his colleagues followed 467 newborns for three years, screening them for allergies annually and testing the dust in the houses where they lived for allergens and bacteria. To the researchers’ surprise, kids who were exposed before their first birthday to mouse and cat dander along with cockroach droppings had lower rates of allergies and wheezing by age 3, compared to those who were not exposed so early on.

In fact, wheezing was three times as common among children who had less exposure to those allergens early in life.

The protective effect of early exposure to allergens was amplified if the home also contained a wide variety of bacteria.

The reason may be that “a lot of immune system development that may lead someone down the path to allergies and asthma may be set down early in life,” Wood said.

Researchers aren’t ready to try to translate the new findings into practical advice for parents. But, Lloret said, we now know that “strict avoidance of allergens from the beginning does not protect you, and early exposure in the right context may make the difference between disease and tolerance. You could say that this is the downside of cleanliness.”

The new findings may upend advice experts have been giving to parents on the topic of pets and newborns.

“Twenty years ago we used to tell parents to get the cats and dogs out of the house,” Wood said. “This shows that the younger the child is when you get a pet, the better.”