Scientists have turned human stem cells into early-stage sperm and eggs in research that promises to give doctors an unprecedented insight into the causes of infertility.

The work will allow researchers to study human reproductive cells from the moment they are created in embryos through to fully-mature sperm and eggs.

Understanding the details of how sperm and egg cells grow will help scientists develop treatments for people who are left infertile when the process goes wrong. The research may also lead to treatments that can correct growth defects before a child is born.

Genetic glitches that happen early on in the growth of sperm and eggs are a major cause of infertility in men and women. The process has been practically impossible to study until now though, because the sex cells form early on, before an embryo is two weeks old.

"This achievement opens a new window into what was only recently a hidden stage of human development," said Susan Shurin at the National Institute of Child Health and Human Development, which part funded the research.

A team led by Renee Reijo Pera at Stanford University in California developed a technique that turned human embryonic stem cells green when they started growing into sperm and eggs. After isolating the reproductive cells, the scientists worked out which genes made them grow properly by switching different genes on and off.

Writing in the journal Nature, the scientists describe how that one gene, called DAZL, is involved in the formation of sex cells from the start. Two related genes are switched on later to steer the cells to full maturity.

The main significance of the work is not to attempt to generate gametes for couples who do not produce them naturally. Rather, the work describes a system in which various aspects of germ cell development can be studied in a dish. In the current study, they have gained insight into the function of three genes in which they specialise."

Darren Griffin, a geneticist at the University of Kent, said the work was important because it gave researchers a way to study human sperm and egg development in a dish, instead of having to rely on tissues taken from animals or "removing bits of people's gonads".

"In future, a range of genetic and environmental factors could be studied, including the effects of pollutants on our fertility. Only through understanding such factors at a basic scientific level can we hope to develop novel diagnoses and therapies. The potential is enormous," he said.

Allan Pacey, an andrologist at Sheffield University, said: "Ultimately this may help us find a cure for male infertility. Not necessarily by making sperm in the laboratory – I personally think that it unlikely – but by identifying new targets for drugs or genes that may stimulate sperm production to occur naturally. This is a long way off, but it is a laudable dream.