In tests, mockups of tortuous female genitalia prevented insemination by males. Warning: Squeamish viewers may find this video unpleasant Yale University

An extraordinary sexual arms race that has played out in duck ponds for thousands of years has been uncovered by evolutionary biologists.

Faced with unwelcome advances from undesirable males wielding large, corkscrew-shaped penises, the females have gone on the defensive.

The solution – the result of millennia of evolution – arrived in the form of vaginas that spiral in the opposite direction, so thwarting uninvited males at a stroke.

Some female ducks possess genitalia of labyrinthine complexity, with kinks, dead ends and hairpin bends, according to a report in the journal Proceedings of the Royal Society B.

Patricia Brennan, professor of evolutionary biology at Yale University in New Haven, Connecticut, decided to investigate the peculiar co-evolution of male and female duck genitalia after previous work revealed stark differences between species.

In some, the males aggressively pursue and attempt to mate with females that are already paired up. The males of these species have by far the largest penises, with some extending to 40cm. In other duck species, the male sexual organ is less than 2cm long.

However, all male ducks have bendy, spiralling penises that extend for copulation.

Two years ago, Brennan's team discovered that only females of species that had to defend against well-endowed, aggressive suitors had convoluted genitalia. The implication was that it was an evolutionary adaptation to keep unwanted males at bay.

For the latest study, Brennan and her colleagues turned to high-speed videography and life-sized models of female duck genitalia to investigate whether the spirals, dead ends and hairpins successfully blocked undesirable males during mating attempts.

Slow motion footage of male Muscovy ducks showed their penises extend with explosive speed, reaching a full 20cm in 0.36 seconds. "We think this allows the male to actually force copulations on females even as they struggle to escape," Brennan said in an email exchange.

The males' attempt at insemination was barely impaired by models of straight and only slightly curved female genitalia, but the more tortuous vaginas effectively blocked the males before they got too far.

"It shows in a very clear way how females can regain control of reproduction. Even though they can't behaviourally prevent males from forcing them to copulate, they have regained control of the 'copulatory area' by preventing males from fully everting their penises when they do not want to copulate," Brennan wrote. "It is really a genital war."

When females choose to mate, they adopt a receptive position and repeatedly contract and release internal muscles that are thought to make copulation easier for preferred males.

"Ducks are absolutely amazing. They are among the most beautiful birds and their courtship displays are famous for their complexity and beauty. They also have this fascinating dark side of struggle and violence and they are teaching us a lot about the evolutionary consequences of conflict," Brennan adds.