We're familiar with drug testing for athletes, but officials at the Beijing Olympics will be taking things one stage further and examining competitors whose sex is in doubt. And it is far from being a new problem, as Emine Saner discovers

For more than a year, officials in Beijing have been designing a special laboratory to determine the sex of any athletes taking part in this year's Olympic games. "Suspected athletes will be evaluated from their external appearances by experts and undergo blood tests to examine their sex hormones, genes and chromosomes for sex determination," says Professor Tian Qinjie. The tests will not be conducted on every female athlete, but will be required if serious doubts have been raised about an individual competitor - invariably one competing in the women's events. "The aim is to protect fairness at the games while also protecting the rights of people with abnormal sexual development," he says.

The International Olympic Committee (IOC) introduced sex testing in 1968 at the Olympic games in Mexico City, after the masculine appearance of some competitors, many pumped up by anabolic steroids, had started to raise questions about the gender of athletes in female events. Unsurprisingly, gender-determination tests were seen as degrading, with female competitors having to submit to humiliating and invasive physical examinations by a series of doctors. Later, the IOC decided to use a supposedly more sophisticated genetic test, based on chromosomes. Women usually have two X chromosomes; men an X and a Y chromosome. So, according to the rules of the test, only those athletes with two X chromosomes could be classed as women. However, many geneticists criticised the tests, saying that sex is not as simple as X and Y chromosomes and is not always simple to ascertain.

It is thought that around one in 1,000 babies are born with an "intersex" condition, the general term for people with chromosomal abnormalities. It may be physically obvious from birth - babies may have ambiguous reproductive organs, for instance - or it may remain unknown to people all their lives. At the Atlanta games in 1996, eight female athletes failed sex tests but were all cleared on appeal; seven were found to have an "intersex" condition. As a result, by the time of the Sydney games in 2000, the IOC had abolished universal sex testing but, as will happen in Beijing, some women still had to prove they really were women.

Transsexuals, who have had a sex change from male to female, can compete in women's events in the Olympics, as long they wait two years after the operation.

The following are some of the more famous instances when female athletes were caught in the gender trap.

Santhi Soundarajan

One of the most tragic recent cases is yet to reach a conclusion. Soundarajan, a 27-year-old Indian athlete, has had to endure public humiliation after she was stripped of her silver medal for the 800m at the Asian games in 2006. Soundarajan, who has lived her entire life as a woman, failed a gender test, which usually includes examinations by a gynaecologist, endocrinologist, psychologist and a genetic expert. The precise results of the test have not been made public, but it has been reported that the likely cause is a condition called Androgen insensitivity syndrome, where a person has the physical characteristics of a woman but whose genetic make-up includes a male chromosome. The Canadian cyclist Kristen Worley, who has undergone sex reassignment surgery, is one of a number of people who are calling for Soundarajan's medal to be reinstated. "It should never have been handled in such a gross manner, amounting to public humiliation because of their ignorance of her condition," Worley has said. "The Olympic movement has been dealing with intersex people since the 1930s. You'd think they would have got the hang of it by now." The humiliation and prospect that her career may be over has taken its toll on Soundarajan. In September, Indian newspapers reported that she had survived a suicide attempt.

Edinanci Silva

Born with both male and female sex organs, the Brazilian judo player had surgery in the mid-90s so that she could live and compete as a woman. According to the IOC, this made her eligible to participate in the games and she competed in Atlanta 1996, Sydney 2000 and Athens in 2004. In Sydney, she beat the Australian judoka Natalie Jenkins, who raised the issue of Silva's gender in a press conference, constantly referring to her as "he". "I have never fought that one before. My plan was not to grip with her, she's - he's - very strong," she said. Silva gave a mouth swab to officials, which proved she was female.

Dora Ratjen

In the 1936 Olympic games in Berlin, Adolf Hitler wanted to show the world the supremacy of the Aryan race - and he needed German athletes to win. Ratjen, notable for her deep voice and her refusal to share the shower room with the other female athletes, was Germany's entry for the women's high jump. She came fourth. Britain's competitor, Dorothy Tyler, who won a silver medal, remembers her. "I had competed against Dora and I knew she was a man," she says. "You could tell by the voice and the build. But 'she' was far from the only athlete. You could tell because they would always go into the toilet to get changed. We'd go and stand on the seat of the next-door cubicle or look under the door to see if we could catch them." Tyler held the world record for the high jump, but when officials wrote to her telling her that Ratjen had broken it, she wrote back. "I said: 'She's not a woman, she's a man,'" she says. "They did some research and found 'her' serving as a waiter called Hermann, so I got my world record back again." Dora, who had been born Hermann Ratjen, had in fact been a member of the Hitler Youth and said that the Nazis had forced him to enter as a woman.

Stella Walsh

At one point, Walsh, a Polish-American sprinter, was the fastest woman in the world. Born Stanislawa Walasiewicz in Poland in 1911, she grew up in the United States, although she represented her country of birth at the 1932 and 1936 Olympics, winning gold and silver medals respectively for the 100m sprint. During her long career, she set more than 100 national and world records and was inducted into the American Track and Field Hall of Fame in 1975. She lived her entire life as a woman, and even had a short-lived marriage to an American man. In 1980, Walsh was killed by mistake during an armed robbery at a shopping mall in Cleveland, Ohio. The postmortem revealed she had male genitalia, although this did not prove that she was a man as she was also found to have both male and female chromosomes, a genetic condition known as mosaicism.

Heidi Krieger

It is believed that as many as 10,000 East German athletes were caught up in a nightmarish state-sponsored attempt to build a race of superhuman communist sports heroes and force-fed cocktails of steroids and other performance-enhancing drugs. One of them was Heidi Krieger, a shot putter. When she was 16, her coach put her on steroids and contraceptive pills and she gained weight, built muscle and started to develop body hair. By 1986, aged 20, she was European champion. Her overdeveloped physique had put a huge amount of pressure on her frame, causing medical problems, while the drugs had caused mood swings, depression and resulted in at least one suicide attempt. By the mid-90s, Krieger underwent gender reassignment surgery and changed her name to Andreas. She had already been confused about her gender, but felt that the drugs had pushed her over the edge. "I didn't have control," Krieger told the New York Times four years ago. "I couldn't find out for myself which sex I wanted to be." At the trial in 2000 of Manfred Ewald, the East German sports official and architect of the doping regime, Krieger said "They just used me like a machine".