In the wet sands of Italy’s beaches, an epic battle of the sexes is playing out. The combatants are flatworms and though their bodies are simple, their sexual habits are anything but. Take the common species Macrostomum lignano. After sex, if a female has been filled with unwanted sperm from an undesirable partner, it can double over, put its mouth over its genital opening, and suck the sperm back out. It’s an easy fix that gives the female control over who fertilises her eggs.

But the sperm can put up a fight. It has a very different shape to the tadpole-like figure of human sperm. At its front, it has a sinuous ‘feeler’ that is uses to anchor itself into the walls of the female genitals. Further down, two large backwards-pointing bristles also help to hold the sperm in place. These barbed sperm can’t be sucked out easily. Even after the worm tries, you can often see several sperm sticking out of the genital opening.

There is another twist to this tale. For this flatworm, every individual is both male and female – they are hermaphrodites. When two of them mate, their male organs (the stylets) penetrate each other’s female organs (the antrums) at the same time. They form a little sexual ring, often spinning as they mate. Watch them go at it here.

A closely related species of flatworm – Macrostomum hystrix – has a very different sex life. It’s also a hermaphrodite but it never forms mating rings. Instead, one flatworm mounts the other and stabs its needle-shaped stylet straight through its partner’s skin, ejaculating directly into the body. This disturbing act is found throughout the animal kingdom – from bedbugs to spiders – and it’s aptly known as “traumatic insemination”. Unlike M.lignano,this flatworm never sucks out sperm after sex, and its sperm is very different. They are smaller and simpler, they don’t have any bristles, and they’re very mobile.

Lukas Schärer from the University of Basel has found that these traits go hand-in-hand. He found that 16 species of flatworm, all within the genus Macrostomum, fall into two distinct groups. In the first group, represented by M.lignano, individuals mate in a ring, try to suck out sperm after sex, and have large, bristly sperm. The second group, represented by M.hystrix, practice traumatic insemination, have small, simple sperm, and never try to suck it out. Among these worms, the shape of the genitals and sperm, and the way they mate have all evolved together in predictable ways.

In the flatworms, Schärer sees a classic example of how the competing interests of males and females can drive the evolution of their bodies and behaviours. We’re used to seeing this conflict at the most obvious level, where males and females choose who to mate with. But even after sex, the battle continues, especially if females mate with many males. The sperm from different males compete with one another for fertilisation rights. Meanwhile, females can exert their own control by selectively removing the sperm of unwanted partners. Females evolve resistance, males evolve persistence.

These pressures apply across the animal kingdom, even in species like the flatworms, where individuals are both male and female. The female end has evolved a behaviour – sperm-sucking – that gives it control over who eventually fertilises its eggs. The male end has evolved sperm that are difficult to remove.

The result of this fierce evolutionary battle is a perpetual stalemate, but some species have broken free by switching tactics. By entering traumatically through the skin, rather than through the genitals, the “male” can bypass the “female’s” resistance altogether. But their sperm now face new challenges – most of all, they need to move around easily. The bristles that so effectively anchored them inside a female’s genitals are now a hindrance, and they’re soon lost. If different “males” inject into the same female, their sperm compete for fertilisation rights within her body. Numbers and agility give them the edge, so the sperm become smaller and more numerous.

As the sperm evolve, so do the worms’ genitals. The stylet adapts to more easily pierce a partner’s skin, becoming sharper and reinforced. The female antrum also changes. In the ring-mating species, its walls are thick to prevent injury from the intruding stylet or the anchored sperm. In the traumatic species, the antrum plays no part in sex, and its walls become thin and simple.

One flatworm – M.finlandense – is probably halfway along this change. We don’t know much about its sex life, but its body provide a clue. Like M.lignano, its sperm still has bristles, but they are short. Like M.hystrix, its stylet is pointed and rigid, but it doesn’t have the thickened edge that all other traumatic inseminators have.

In fact, Schärer found that the flatworms have made this switch at least twice, independently ending up with the same sperm, genitals and behaviours. He sequenced genes from his 16 species to find out how they are related to one another. His family tree clearly showed that the traumatic group are more closely related to each other than to the ring species. The only exception is M.hystrix, a lone traumatic inseminator within a group of ring-maters. It evolved the traumatic lifestyle on its own.

But why study flatworms at all? The answer is simple – they are transparent. It can be very difficult to study sexual conflict because, for obvious reasons, it’s not easy to see what happens to sperm inside the female’s body. Scientists have to come up with ingenious solutions, like genetically engineering animals with glowing sperm. But that’s not a problem if you can see straight through your animals of choice. To Schärer, the flatworms provide a literal “window of opportunity” for understanding the evolution of sperm, the most diverse group of cells in the animal kingdom.

PS: Schärer’s website has a great page of flatworm merchandise, including soft toys and mating-ring cookies! He writes, “Macrostomum has inspired a wealth of people in other crafts than science, especially bakers and confiseurs, but also toy designers have recently joined the frenzy.”