A pregnant mother's placenta can transmit damaging effects of stress to her unborn child, say researchers.
The impact is felt by a protein that affects the developing brains of boys and girls differently.
Scientists believe it could explain known links between maternal stress and disorders such as autism and schizophrenia, which are more common and serious in male offspring.
"Almost everything experienced by a woman during a pregnancy has to interact with the placenta in order to transmit to the foetus," said lead researcher Dr Tracy Bale, from the University of Pennsylvania's School of Veterinary Medicine in the US.
"Now we have a marker that appears to signal to the foetus that its mother has experienced stress."
The researchers studied female mice that were exposed to mild stresses such as the smell of foxes or unfamiliar noises during the first week of pregnancy.
They identified an enzyme called OGT that was present at lower levels in the placentas of stressed mice than in unstressed mice. Male offspring placentas also had lower natural levels of OGT than those attached to female offspring.
Further research showed that cutting levels of OGT triggered changes in more than 370 genes in the brains of unborn mice.
Many of these genes play a role in functions critical to neurological development, such as energy use, protein regulation and creating nerve cell connections.
The findings, reported in the journal Proceedings of the National Academy of Sciences, are likely to translate to humans, say the researchers.
Analysis of human placentas discarded after the birth of male babies showed evidence of reduced OGT levels.
The results suggest that OGT may protect the brain during pregnancy. Males have less of the protein to begin with, placing them at greater risk if their mothers are stressed.
"We want to get to the point where we can predict the occurrence of neurodevelopmental disease," said Dr Bale.
"If we have a marker for exposure, we can meld that with what we know about the genetic profiles that predispose individuals to these conditions and keep a close eye on children who have increased risks."