Judges at the Swiss Federal Tribunal reversed a temporary suspension on the testosterone-curbing rules introduced in May 2018 by world athletics governing body the International Association of Athletics Federations (Iaaf) for female athletes with naturally high testosterone competing in events from the 400m to a mile.
Semenya challenged the Iaaf move at the Court of Arbitration for Sport.
However in May 2019, she lost that case but appealed the decision at the federal court which said the Iaaf rules should be temporarily suspended.
That allowed Semenya to compete in a 2,000m race in Paris as well as in the 800 metres at the Prefontaine Classic Diamond League meet on 30 June in California. There she came in ahead of the American trio Ajee Wilson, Raevyn Rogers and Hanna Green.
But with a judge at the Swiss court reversing the decision, it scuppers Semenya's bid to eclipse her rivals again on the track at the world championships between 27 September and 6 October in Qatar.
In a statement issued through her PR agency, Semenya said: “I am very disappointed to be kept from defending my hard-earned title, but this will not deter me from continuing my fight for the human rights of all of the female athletes concerned.”
The Iaaf said on Wednesday that the Swiss court's decision would help athletes understand the regulations.
"The Iaaf welcomes the Swiss Federal Tribunal's decision to revoke its super-provisional order after hearing the Iaaf's arguments.
"This decision creates much needed parity and clarity for all athletes as they prepare for the world championships in Doha this September."