Of all the obstacles athletes have had to overcome to compete in the Olympics, perhaps the most controversial has been the gender test.

Originally designed to prevent men from competing in women’s events, it is based on the premise that competitors can be sorted into two categories via established scientific rules. But the biological boundaries of gender aren’t always clear.

Consider the Spanish hurdler Maria Jose Martinez-Patiño. A gender test revealed that she had a Y chromosome, which normally makes a person male. She also had complete androgen insensitivity syndrome, or CAIS, which prevented her body from responding properly to testosterone and caused her to develop as a woman.

The Spanish Athletic Federation got her test results in 1986, just before a major competition that would have set her up for an Olympic run. Though she won the 60-meter hurdles, the federation declared her ineligible for the 1988 Summer Games in Seoul.

The International Olympic Committee has struggled with cases like these, variously using hair patterns, chromosomes, individual genes and other factors in their long-running attempts to distinguish men from women. All of these tests have been discarded.

For the London Games, officials are going by a new set of rules that shifts the focus from DNA to testosterone, a hormone that aids muscle development, endurance and speed.

To a group of increasingly vocal skeptics, the very notion of gender testing is flawed and efforts to measure it biologically are doomed to fail. But some experts said they had to try anyway.

“There is no single metric for sex or athletic potential,” said Eric Vilain, director of the Center for Gender-Based Biology at UCLA. But he called the new testosterone-based test a pragmatic solution to a real problem. “I have talked to many elite female athletes, and I haven’t found one who is comfortable with the idea of having no testing,” he said.

Once it’s agreed that men and women should compete separately, how should officials divide them up?

It’s not a rhetorical question. Though most people fall neatly into “male” and “female” categories, some do not. The fact that there are people with physical or genetic traits of both sexes prompted the IOC to rethink its gender test.

The new rules, announced last month, disqualify athletes from women’s events if they have testosterone levels in the normal male range, which is 7 to 30 nanomoles per liter of blood. Because the top range for women is slightly below 3 nanomoles per liter, such levels could give athletes an unfair advantage that officials have a duty to root out, said Dr. Arne Ljungqvist, chairman of IOC’s Medical Commission and a former Olympic high jumper. Athletes with complete androgen insensitivity will be allowed to compete.

It’s impossible to say how many athletes in London will be affected by the new test, Ljungqvist said. Unlike past tests, which were given to all competitors in women’s events, this one will be administered only when the chief medical officer of a national Olympic committee or a member of the IOC’s medical commission requests it.

Ljungqvist said the test had a narrow purpose: “We are not determining the gender in an individual. What we are talking about is athletic eligibility.”

Most of the studies linking more testosterone with better athletic performance have been small and focused on men. Its value to female athletes is hazier.

“We don’t know much about the biological characteristics of testosterone in healthy women,” said University of Michigan biopsychologist Sari van Anders. “People only tend to look at testosterone in women when there’s a health issue.”

The picture is particularly murky for Olympic-caliber women. Experts know of only one report on the relationship between testosterone and performance of elite female athletes. That study of 22 sprinters and volleyball players found that those with the highest levels could jump about 4 inches higher than those with the lowest levels.

But if testosterone were essential to athletic success, Martinez-Patiño would have been doomed to fail because her body can’t use the hormone. Many women with androgen insensitivity have competed in the Olympics, and “the idea that testosterone is a necessary ingredient for elite athletic performance is really undermined by these cases,” Van Anders said.

In fact, androgen insensitivity is overrepresented among female athletes, Vilain added: The general population has an incidence of 1 in 20,000, but for Olympic athletes it is about 1 in 400. No one knows why.

Vilain participated in the IOC’s deliberations over the testosterone test and said the new rules, while imperfect, were a step in the right direction.

“If we could just have a social answer and let everyone declare their own sex, that would be great,” he said. But “if we say, ‘Anyone who says they’re a woman is a woman,’ I worry that people will always take advantage of that.”

Accusations of men masquerading as women in the Olympics go back at least as far as 1936, the year questions were raised about American sprinter Helen Stephens after her upset win at the Berlin Summer Games. Stephens passed some sort of gender test — the details are lost to history — and was awarded a gold medal.

The Cold War raised tensions between the U.S. and Soviet-bloc teams. Whispers about men posing as women were rampant on both sides, leading the IOC to devise a testing procedure in the 1960s. Athletes had to parade nude in front of physicians, submit to genital exams and have their hair patterns analyzed before they could receive certificates of femininity.

In 1967, that gave way to a more scientific test based on DNA. In people with two X chromosomes, one of them is inactivated and curls up into a tight ball, which the test detects. But the test proved inadequate in cases of conditions like complete androgen insensitivity syndrome, in which athletes had an X and a Y chromosome but the biological appearance of a woman.

Martinez-Patiño fought her case for two years, enlisting experts to prove that her XY status gave her no advantage because her body could not benefit from extra testosterone.

Officials reinstated her in 1988, just a few months after the Seoul Games. At the 1992 Olympic trials leading up to Barcelona, she missed qualifying for the Spanish team by one-tenth of a second.

After her case, the IOC switched to a test based on a gene called SRY, which initiates testes development. But since the gene is on the Y chromosome and merely tests for that chromosome’s presence, it suffered the same flaws. Eight female athletes failed the SRY test at the 1996 Atlanta Games, though all had androgen insensitivity and were ultimately cleared to compete.

That convinced the IOC to drop routine gender testing, but it and the International Assn. of Athletics Federations retained the right to test those suspected of competing under false pretenses or with medical conditions offering an unfair advantage.

That’s how South African runner Caster Semenya came to be tested at the 2009 World Championships in Athletics in Berlin. Her masculine face and build prompted accusations that she was a man.

The international association conducted an inquiry and cleared her to race after a 10-month ban. She carried her country’s flag in the opening ceremony for the London Games.

Association officials were criticized for the seemingly arbitrary nature of their inquiry. The new IOC policy is crafted to be more transparent, Ljungqvist said.

To Martinez-Patiño, now a professor of sports science at the University of Vigo in Spain, the new rules echo the old — they just use a different metric. “Over time they will conduct research and demonstrate the ineffectiveness of this test,” she said, “just as has happened with the others.”

jon.bardin@latimes.com