Penises come in many shapes and sizes in the animal kingdom. But usually they're only ever found on the sperm-owner of a species. 

In the strange case of a tribe of cave-dwelling winged insects found in Africa and Brazil though, it's the egg-laying females who grow a phallus – albeit, not one that ejaculates sperm, although it plays a crucial role during sex.

It's clearly a winning idea for them too, seeing as the appendages evolved more than once in their history.

You might know the primitive order of insects known as pscoptera better under their common names: barkflies or book lice.

Four years ago, a team of Japanese researchers discovered a genus of these insects in a Brazilian cave with some odd-looking sex organs. Researchers have now carried out phylogenetic research on three members of a tribe within this order, to better understand why their respective reproductive bits function the way they do.

Females of the psocid genera Neotrogla have extended hook-like structures which for all purposes look and act like a phallus. Conversely, males lack the usual clasping organs expected of their order, with a small vagina-like pouch in place instead.

In a reversal of the usual exercise of copulation, during sex females of the genera grab the male with their hooked penis, hold tight, and receive their mate's sperm. This gender-flipped hook-and-pocket set-up is apparently used to prevent males from escaping for the 40 to 70 hours – yes, hours – it takes to do the deed.

To get technical, 'penis' isn't quite the right term for the appendage, which the researchers specify as a 'gynosome' to distinguish it from the kinds of ejaculatory organs used by males in other species.

In spite of their variety across the animal kingdom, penises serve a similar primary purpose; to bring sex cells close together.  

But while female penis-like structures can be found elsewhere in nature – such as in the form of an oversized clitoris in spotted hyenas – they aren't ever used for penetration, let alone delivery of eggs to the site of a sperm party.

That makes this psocid's gynosome a stand-out example. Only one other genus in its tribe, a genus found in southern Africa called Afrotrogla, shares such an appendage.

But the gynosomes of the species within the two genera are also nothing alike. Those of Neotrogla have a hardened tip with an inflatable balloon-like structure at the base. The gynosome in Afrotrogla, by contrast, has hardened edges that don't seem to resemble anything found on its relative.

Stranger still, a genus closely related to Afrotrogla, called Sensitibilla, is having none of this pseudo-penis business, sticking to traditional gender roles.

This made researchers wonder if the two different gynosomes evolved twice after the three genera went their separate ways, or if Sensitibilla tried it out for a while before returning to the method of reproduction used by its ancestors.

A close inspection of the anatomy of these three genera has now convinced the researchers that these female-penis structures did indeed develop independently.

This leaves an intriguing mystery – what prompted two groups of related insect to evolve penis-like structures in females, bucking the trend of virtually every other animal species on the planet?

Their habitat could offer a few clues. Caves – such as those Neotrogla and Afrotrogla evolved in – are regarded as extremely oligotrophic, meaning competition over nutrients is high.

Male book lice living in these caves aren't likely to hand out their precious sperm packages willy-nilly. Sure, it might mean more offspring, but not when it risks starvation.

But it seems the females in their vicinity weren't willing to sit around waiting for them to pick and choose. With sperm now a precious commodity, it was up to them to aggressively hunt for it.

Variations in the structures of gynosomes and male pouches between species of Neotrogla seem to back this up, with the males and females evolving respective jigsaw-puzzle shapes of spines and depressions to accommodate one another.

Similar co-evolved shifts in reproductive anatomy between males and females have also been noticed in other insect species found in isolated locations, such as fruit flies breeding on islands and a species of diving beetle in a single pond in Japan.

While the exact processes behind these shifts aren't yet clear, it seems that the coercion and resistance between male and females of a species is closely linked to the environment, such as prey and predation.

And, as always in nature, when the pressure is on to survive, sometimes it pays to switch things around a bit and break the rules.

This research was published in Biology Letters.