The researchers suggest that exposure to animals and the bacteria they carry might be strengthening the foetus's immune system.
Writing in the European Respiratory Journal, they said exposure before and after birth halved the risk.
But experts warn some animals carry infections which may harm the baby.
The research, carried out at Massey University, adds to other studies which have suggested that living on a farm, with regular contact with animals, during the early years of life, could cut the risk of asthma and other allergic diseases.
But the study of more than 1,300 farmers' children goes further, suggesting that this protection could start building even before birth.
It found that the greatest apparent protection - a 50% reduction in asthma, and an even greater reduction in eczema and hay fever - was gained by children whose mothers had been exposed to farm life during pregnancy, and who currently lived on a farm.
The reasons why this might happen are unclear, although they are likely to be related to the way that the child begins to develop its immune system.
Living on a farm means frequent contact with animal bacteria, perhaps through the consumption of unpasteurised milk, or contact with the animals directly.
The researchers suggested that this might suppress the production of particular immune cells linked to the development of asthma.
However, they suggested that while exposure during pregnancy might be useful, it might only persist if the child was exposed after its birth as well.
The findings are unlikely to lead to any change in current advice to pregnant women, which urges caution about contact with certain farm animals.
In particular, an infection which can cause miscarriage in pregnant ewes can lead to the same result in humans.
The faeces of other animals can also carry infections which can affect a pregnancy, BBC reports.
Dr Elaine Vickers, research manager at Asthma UK, said: "This study adds to existing evidence supporting the hygiene hypothesis, which states that early exposure to potential allergens results in a reduced risk of asthma development.
"However, the causes of asthma are still largely unknown and the processes involved in asthma development are incredibly complicated, including family history, environment and lifestyle."