Giving birth to a boy can significantly increase the risk of some women having subsequent miscarriages
Scientists believe male genes can trigger an immune reaction that prevents later pregnancies in vulnerable women.
Among a group of miscarriage sufferers who had previously given birth, the chances of having a second child were reduced by nearly two thirds for those with a first born boy.
Normally about 1% of women experience recurrent miscarriages - defined as having three miscarriages one after the other.
In a third of these cases, the woman involved had previously delivered a normal child.
Doctors at a fertility clinic in Denmark noticed they were treating an unusually high number of women with the problem whose first born child had been a boy.
They decided to investigate the trend, and discovered a strong connection.
Out of 305 women suffering unexplained recurrent miscarriages, 60% had first born children who were boys, rather than the expected 51%.
Of those who were successfully treated and eventually had another baby, 56% had first born boys. But treatment was successful in 78% of the women whose first born had been a girl.
Compared with patients who had earlier given birth to girls, women with first born boys had only a 37% chance of having a second child after treatment.
The recognised treatment for recurrent miscarriages is a blood product that dampens down the immune system.
This could provide a clue to why having a baby boy might impair a woman's subsequent chances of giving birth, say the scientists, whose findings were presented today at the annual meeting of the European Society of Human Reproduction and Embryology in Prague.
Dr Henrietta Svarre Nielsen, who led the research at the University Hospital, Copenhagen, said: "It's known that a woman's immune system is affected when she carries a male foetus.
"Up to 22 years after she has delivered a boy you can pick out cells in her immune system showing activity against males.
"We think there is an immune response against genes from the male Y chromosome."
She said bone marrow transplants from women to men were often unsuccessful if the woman had previously given birth to a boy.
It was likely that an immune reaction which started out targeting male cells grew to the point where girls were affected too, she added. As a result, a woman could be prevented from having a baby of either sex.
"It may be that the immune reaction spreads out to affect all children," said Dr Svarre Nielsen. "The immune response gets bigger and bigger and more cells get attacked. In the beginning you need to be pregnant and carrying a boy, but later you just need to be pregnant."
She stressed that only a small group of women, possibly with defective immune systems, were susceptible to the problem. Most women's bodies tolerated the presence of a boy foetus with no ill-effects.
"The fact that we can now detect a defect might give us a clue to what happens in a normal pregnancy," added Dr Svarre Nielsen.
Boy babies boost miscarriage risk