The suggestion that two transgender women were close to being selected for the British Olympic team was met with outrage earlier this month. LGBT advocates were upset that trans athletes would have to face any queries at all over their right to compete as women, while others insisted that only “biological females” should do so. We are assured that the inclusion of trans women in Olympic sports, which is now possible after a rule change, is unfair because they will have a “natural advantage” over other women. Detractors accuse trans athletes, in advance, of cheating. We’re all for transgender rights, many argue, but this is taking it a bit far. What if they win?

I don’t pretend to have extensive know­ledge of the sporting mindset, but I thought that winning was rather the point. As for a biological advantage – most athletes have one. That’s why they’re athletes. The best swimmers have broad shoulders; the best basketball players are freakishly tall. If there is any such thing as an average male or female body, you’d have a hard job finding it in an Olympic team.

The debates about sport show just how difficult it is to draw a sharp distinction between men and women, between male and female bodies. What should a “woman” be, for the purposes of professional sport?

The International Olympic Committee (IOC) first introduced gender testing in 1968 but the dividing lines have since shifted. Hormone testing has become the “true” arbiter of gender, even though testosterone levels vary hugely among individuals, as well as between men and women as groups. What is the difference between an intersex athlete who has undescended testes producing testosterone and someone such as the Indian sprinter Dutee Chand? In 2014 Chand was barred from the Commonwealth Games because she has hyperandrogenism, which gives her unusually high (naturally occurring) testosterone levels. After she appealed to sporting officials, the rules relating to her condition were suspended, and she will be competing in Rio.

Also heading for the Olympics this summer is the South African runner Caster ­Semenya. In 2009, after it was observed that she was a very muscular person indeed, she was threatened with confiscation of her medals, forced to undergo gender testing and endured scurrilous speculation about her “real” sex. She underwent hormone therapy to be allowed to compete again.

For a while, it was assumed that chromosomes could tell us someone’s “true” sex: XX for women, XY for men. Nature, however, is not that binary. In the 1960s the Polish athlete Ewa Kłobukowska was found to have a rare genetic condition – XX/XXY mosaicism – which gave her no advantage over other athletes. Nonetheless, she was banned from competing in Olympic and professional sports.

The history of these people, banned and sometimes unbanned, should teach the medical profession to be less sure about its conclusions. As for these women’s detractors, there are times when you have to wonder what story people think they’re living in. Even the most culturally oblivious commentator can recognise when they have become the villain in a feel-good sports movie about plucky underdogs overcoming prejudice. Surely someone on the IOC has seen Cool Runnings?

Yet the question remains: what are exceptional athletes to do when they don’t fit into arbitrarily chosen biological categories on whose terms excellence is measured? Sit out and watch?

In sport, bodies are quite literally contested. Women’s participation was always an afterthought: the 2012 games in London were the first Olympics in which women took part in every sport. Strict gender segregation is seldom questioned, which conveniently allows women’s events to be sidelined while ensuring that no sportsman will ever be beaten by a woman. But dividing sports by gender isn’t natural or inevitable. Even if you believe that men are always faster and stronger than women, there are other ways to organise tests of ability, including by weight class and performance history.

It is worth remembering that successful women have always been required to prove their gender in public – although sports are one of the few areas in which they may also be called before a medical board. The femininity of female politicians, entrepreneurs and artists is routinely called into question. Drive and ambition are associated in the popular imagination with maleness. If you want to win, you must not be a real woman. If you care more about being successful than being agreeable, you are considered unwomanly.

Trans athletes are not the only women in sport to have faced this furore. Consider the abuse hurled at female tennis champions, especially Serena Williams. Whenever she wins a major event, she is abused over her choices of outfit, the size of her muscles, and whether or not you could see her nipples through her shirt as she was flattening her opponent.

Shortly before Marion Bartoli won the Wimbledon singles title in 2013, the BBC presenter John Inverdale wondered on air if the French tennis player pushed herself to excel because her father had told her, “You’re never going to be a looker.” Since her retirement from the professional singles game, Bartoli has lost so much weight that Wimbledon’s organisers asked her to withdraw from an exhibition doubles match on “medical” grounds this year.

Gender, like sports, can seem simple from the outside, based on straightforward and inflexible rules. But both are human creations and both are never as simple, never as rigid and never as objective as we might like to think. The crucial difference is that, with gender, nobody gets to sit in the stands and watch: like it or not, we all have to play.