Hermaphroditism and protogyny.
The hamlet bass is a hermaphrodite (one individual has both testes and ovaries) and switches sexual roles during mating.
Here a male-acting fish curls around its partner, fertilizing "her" eggs.
The bluehead wrasse exhibits sequential hermaphroditism, or protogyny:
the largest female in a population turns into a male when the dominant male is absent.