Children who are raised in households with dogs or farm animals during their first year of life may have a lower risk of asthma a few years later, a new study suggests.

In the study, the researchers looked at early exposure to dogs and farm animals and the rate of asthma among about 377,000 preschool-age and 276,000 school-age children in Sweden.

Among the school-age kids in the study, those who had been exposed to dogs during their first year of life were 13 percent less likely to have asthma at age 6, compared with the school-age kids who had not been exposed to dogs in their first year of life, the researchers found.

Based on the new findings, researchers can confidently "say that Swedish children with dogs in their homes are at lower risk of asthma at age 6, and that this risk reduction is seen also in children to parents with asthma," said study author Tove Fall, an associate professor of Uppsala University in Sweden.

The researchers also found that, the school-age kids who were exposed to farm animals during their first year of life were 52 percent less likely to have asthma at age 6 than those who had not been exposed to farm animals during their first year of life. [10 Things You Didn't Know About Dogs]

Among the preschool-age children, those who were exposed to farm animals during their first year were 31 percent less likely to have asthma when they were between 1 and 5 years old, compared with the kids who were not exposed to farm animals during their first year of life, according to the study, published today (Nov. 2) in the journal JAMA Pediatrics.

In the study, the researchers looked at diagnoses of asthma obtained from the National Patient Register in Sweden. They also examined data on prescribed asthma drugs dispensed at pharmacies in Sweden. The researchers also looked at whether the kids' parents were registered as dog owners during the child's entire first year of life, and whether the parents reported that they worked with farm animals. The data in the study were analyzed from January 2007, through September 2012.

The researchers said they don't know for sure what exactly may explain the link between early exposure to animals and a reduced risk of asthma.

"It might be due to a single factor, or more likely, a combination of several factors related to a dog ownership lifestyle or dog-owners' attitudes, such as kids' exposure to household dirt and pet dust, time spent outdoors or being physically active," Fall told Live Science. "As a parent in a dog-and-baby-household, it is nearly impossible to keep everything clean, and maybe this is a good thing for your baby's future health."

Currently, one of the main hypotheses that aim to explain the link between a lower risk of asthma and early exposure to pets is that "kids in animal environments breathe air that contains more bacteria and bacterial fragments, which actually could lower their risk of asthma," she said.

Previous research on having pets and the risk of asthma in kids has yielded mixed results. For example, the results of a 2001 review of previous studies suggested that exposure to pets was linked to an increased risk of asthma in children. But a 2012 review suggested that exposure to pets, especially dogs, was tied to a decreased risk of asthma and allergies in childhood.

"My take-home message from this study is that parents at this point do not need to worry about keeping their dog or getting a puppy when expecting a baby for fear of asthmatic disease," Fall said. "I do want to be clear that this recommendation is valid only for families without a child already having allergies. If they already have a furred-animal-allergic child, we do not recommend them to get a furred pet."

The new findings are in line with the so-called hygiene hypothesis, said Dr. Purvi Parikh, an allergist and immunologist with Allergy & Asthma Network, a nonprofit organization that promotes allergy research and education, who was not involved in the new study.

According to this hypothesis, being exposed to bacteria early in life is crucial for shaping a healthy immune system, and may play a role in modifying a person's risk of developing asthma and allergies.

"With allergies and asthma, it is partially genetic, but studies like this do show us that your environment does play a key role in the development of your immune system, and the development of allergies and asthma," Parikh told Live Science.

Follow Agata Blaszczak-Boxe on Twitter. Follow Live Science @livescience, Facebook & Google+. Originally published on Live Science.