Millions of years ago, when vertebrates evolved from the sea to land, they had to go through some evolutionary changes, including the development of sex organs. Now, new research is shedding light on these genetic changes after turning lizard limbs into genitalia in the lab.

According to a study published in the journal Nature, the key to the origin of genitalia lies in the limbs, at least in snakes and lizards. When it comes to sex organs, lizards and snakes have two, while birds and humans have only one. But, in contrast to ours, the paired structures of these reptiles are located somewhat at the level of their limbs. In fact, snake and lizard genitalia are derived from tissue that gives rise to hind legs, while mammalian genitalia are derived from the tail bud.

To learn more about this evolutionary process, scientists from Harvard Medical School initially set out to understand why snakes don't develop limbs. Later, they discovered that the earliest stages of genital development closely resembled limb formation.

More importantly, when given a nudge, lizard limbs were successfully turned into genitalia.

"It demonstrates that there is a flexibility with what kind of cells can get recruited during development to form genitalia," lead author of the research, Dr. Patrick Tschopp, explained to BBC News.

To do this, researchers moved the position of the cloaca - an embryonic "signaling source" that tells neighboring cells and tissues to form into external genitalia. In snakes and lizards, the cloaca is normally found near tissues that give rise to limbs, but in the lab Tschopp and his team moved it into either limb or tail bud cells.

In both cases, cells located near the cloaca converted into genitalia cells.

"In other words, by misplacing a molecular signal you can misguide these cells in their developmental trajectory," added Tschopp.

The results show, in a sort of evolutionary twist, how genitals and limbs have a shared ancestry, and that, for snakes, lizards and other vertebrates alike, genital evolution was another adaptive measure vital for living on land.