Male fertility problems are determined in the womb, research from the University of Edinburgh suggests.
Common genital disorders, low sperm count and testicular cancer could all be linked to hormone levels early in pregnancy, studies in rats suggest.
It was found that levels of male hormones, such as testosterone, in a critical "window" at 8-12 weeks determine future reproductive health.
The results are published online in the Journal of Clinical Investigation.
Problems with reproductive development such as the testes not descending properly into the scrotum (cryptorchidism) or the urinary tract opening in the wrong place on the penis (hypospadias) are fairly common in young boys.
Other disorders, such as low sperm counts and testicular cancer, are thought to be part of the same pathway.
Using the mouse model, researchers at the Medical Research Council Human Reproductive Sciences Unit found the disorders resulted from low levels of male hormones - or androgens - at the equivalent to 8-12 weeks human gestation.
They also found that the level of androgen hormone at this time was related to the distance between the base of the penis and the anus.
This measurement could be an early warning system of future reproductive problems in baby boys, they said.
It could also give insights into links between hormones in the womb and fertility problems in later life.
Study leader, Dr Michelle Welsh, said: "We know from other studies that androgens work during foetal development to programme the reproductive tract.
"But our assumption was that it would be much later in pregnancy."
She added the anogenital measurement would be a useful tool.
"Say a clinician were to examine a 30-year-old man with testicular cancer - previously there would have been no way of knowing what hormones he was exposed to in the womb.
"We would suggest that this measurement, even at this later stage in life, could offer an indication of hormone exposure."
"For example, the shorter the distance, the less confident we can be that hormones have acted correctly and at the right time."
Co-author, Professor Richard Sharpe, said around 7% of boys had cryptorchidism and low sperm counts effect as many as one in five young men.
Dr Allan Pacey, senior lecturer in andrology at the University of Sheffield, said scientists had been worried for many years about the increasing incidence of problems resulting from disrupted development of the male reproductive system during pregnancy.
"Understandably, this is almost impossible to study in humans directly and so animal models are needed to unravel the precise details.
"To use the adult anogenital distance as a proxy marker of foetal exposure in utero is a good suggestion and I would encourage studies to investigate how well this correlates with problems of the male reproductive system."