Infant gut microbiotas were studied from fecal samples collected around three months old.
The researchers compared whether the babies were exposed only during pregnancy, or both pre- and postnatally, to no pet exposure.
Over half of the studied infants were exposed to at least one furry pet in the pre- and/or postnatal periods - 70 percent being dogs.
Researchers found that pre- and postnatal pet exposure enriched the amount of two types of bacteria in the gut with more than a twofold greater likelihood of high abundance.
Ruminococcus and Oscillospira have been linked with reducing childhood allergies and obesity, respectively.
"The abundance of these two bacteria were increased twofold when there was a pet in the house," said Dr Anita Kozyrskyj, a University of Alberta pediatric epidemiologist.
She added that pet exposure was shown to affect the gut microbiome indirectly - from dog to mother to unborn baby - during pregnancy as well as during the first three months of the baby's life.
In other words, even if the dog had been given away for adoption just before the mother gave birth, the healthy microbiome exchange could still take place.
The study also found that having pets at home reduced the likelihood of the transmission of vaginal GBS (group B Strep) during birth.
The bacteria can cause pneumonia in newborns and is prevented by giving antibiotics to the mother during delivery.
Past research has found that pets are beneficial for human health in a number of ways.
Several studies have shown spending just a few minutes with a furry friend can lower anxiety and blood pressure and increase levels of serotonin and dopamine, two neurochemicals that play roles in producing feelings of calm and well-being.
And a study from the American Psychological Association found that pet owners over age 65 make 30 percent fewer visits to the doctor.
Although the researchers say it's too early to predict how the findings will play a role in the future, Dr Kozyrskyj doesn't rule out the concept of a "dog in a pill" as a preventive tool for allergies and obesity.
"It's not far-fetched that the pharmaceutical industry will try to create a supplement of these microbiomes, much like was done with probiotics," she said.
Bacteria is key to preventing allergies in kids
Children could be stopped from developing allergies and asthma by altering their stomach bacteria in their first few months of life, a study has found.
Our increasingly sanitized world where children receive very little exposure to the bacteria of nature has led to an explosion in allergies, scientists say.
But by introducing mixtures of beneficial bacteria into the stomach of babies at risk mean they are less likely to develop allergies or asthma.
Both conditions are usually only noticed after the age of four - raising the possibility that the conditions could be stopped before they develop.
The scientists, publishing in Nature Medicine, found that particular patterns of germs found in the stomachs of one-month-old infants meant they had a three times higher risk of developing common allergic reactions by 24 months and asthma by four months.
Dr Susan Lynch, a professor of medicine at the University of California at San Francisco, said she believes the discovery represents an opportunity to develop new treatments that could stave off allergies and asthma before they become established.
She said: "If we are to prevent disease development, we need to intervene early."