Female bluehead wrasse can step in when the dominant male dies and change sex in about 10 days, scientists have learned.
She can alter her behaviour within minutes, her colour from yellow to blue within hours and, in as little as 10 days, her ovaries are replaced by testes capable of producing sperm.
While it's known that about 500 species of fish, such as the clownfish from Finding Nemo, routinely change their sex in adulthood as a natural part of their life-cycle, this research into the bluehead wrasse is the first time to unravel just how they do so.
Co-lead author Dr Erica Todd, of the University of Otago in New Zealand, said: "When a dominant male is lost from a social group, the largest female transforms into a fertile male in 10 days flat.
"Females begin this transformation within minutes, first changing colour and displaying male-like behaviours.
"Her ovaries then start to regress and fully functional testes grow in their place.
"How this stunning transformation works at a genetic level has long been an enigma."
She said they discovered the sex change involved a complete genetic rewiring of the gonad.
"Genes needed to maintain the ovary are first turned off, and then a new genetic pathway is steadily turned on to promote testis formation."
This chain reaction begins when a gene called aromatase, which is responsible for making the female hormone estrogen, is turned off.
What triggers aromatase to turn off is unknown, but the stress of social change resulting from the loss of the existing dominant male may be an important signal in turning off the genetic pathway that maintains the ovary.
Co-lead author PhD candidate Oscar Ortega-Recalde, added that the transformation also appears possible through changes in cellular "memory".
He said: "In fish and other vertebrates, including humans, cells use chemical markers on DNA that control gene expression and remember their specific function in the body.
"Our study is important because it shows that sex change involves profound changes in these chemical marks, for example at the aromatase gene, thus reprogramming cell memory in the gonad towards a male fate."
As many genes important for sexual development in fish are also important in other animals, the team’s discovery has practical applications for humans.
“Understanding how fish can change sex may tell us more about how complex networks of genes interact to determine and maintain sex, not only in fish but in vertebrate animals generally,” Dr Todd said.