Famed South African Olympian Caster Semenya has been barred from participating in September's Athletics World Championships.

On Tuesday, a Swiss judge upheld a previous decision that would have forced the two-time Olympic gold medalist and three-time world champion to take medication or change races in order to compete.

Semenya is one of the world's best women's runners in the 800m race. But she has been locked in a legal battle with the Court of Arbitration for Sport and the International Association of Athletics Federations.

The sporting body passed a rule last year that forces athletes with differences of sexual development (DSD) to take testosterone-reducing medication in order to compete in track events from 400m to the mile.

With her country heavily supporting her, the 28-year-old track star has said she will never take medication. She called the new rules discriminatory.

"I am very disappointed to be kept from defending my hard-earned title," she said in a statement on Wednesday.

"But this will not deter me from continuing my fight for the human rights of all of the female athletes concerned."

The court initially agreed with Semenya and blocked the rule from being imposed.

But a single Swiss Federal Supreme Court judge ruled on Tuesday that while the case makes its way through other courts, the sporting body should be allowed to impose the rule on women runners worldwide.

The IAAF has defended their decision, claiming women like Semenya have a genetic biological advantage that makes it unfair for them to race against other women.

"In the remainder of the proceedings before the SFT, the IAAF will maintain its position that there are some contexts, sport being one of them, where biology has to trump gender identity, which is why the IAAF believes (and the CAS agreed) that the DSD Regulations are a necessary, reasonable and proportionate means of protecting fair and meaningful competition in elite female athletics," they said on Wednesday.

"This creates much needed parity and clarity for all athletes as they prepare for the World Championships."

Because of the ruling, Semenya will not be able to defend her title in the 800m World Championships, which will be held in Doha. Since she sued and won her first appeal, she has been allowed to race.

Last month, she ran the fastest 800m time ever on U.S. soil at the Prefontaine Classic Diamond League.

But she has been open about how stressful, disruptive and discouraging the situation has been for her and her family.

"Caster Semenya remains steadfast in her defiance of the highly controversial IAAF regulations that require female athletes with naturally elevated testosterone levels to undergo hormonal drug intervention in order to compete in international competitions," the runner's lawyers said.

Dorothee Schramm, the lead lawyer for Semenya, said the decision was purely procedural and had little effect on their broader appeal of the rule.

"The judge's procedural decision has no impact on the appeal itself," she said.

"We will continue to pursue Caster's appeal and fight for her fundamental human rights. A race is always decided at the finish line."