An international sports court has opened the door to Russian athletes seeking to overcome doping bans at the Rio Olympics by ruling that an International Olympic Committee (IOC) ban on athletes for past doping offenses is unenforceable.

The ruling on the eve of the games starting on August 5 came as the IOC announced that 271 of Russia's 389 Olympic athletes were cleared to participate, including all 20 Russian gymnasts.

Some of Russia's 118 athletes officially barred from the games could get reinstated, however, because of the court's ruling.

The Court of Arbitration for Sport (CAS) reinstated two Russian rowers and a swimmer who had been banned by their sport federations last week because of their histories of doping. The federations banned them following instructions to do so from the IOC on July 24.

The court said the bans were unenforceable because an athlete cannot be sanctioned twice for the same doping offense. It added that the committee's order to ban them "does not respect the athletes' right of natural justice."

The court acknowledged its August 4 decision could invite a dozen more appeals against doping bans from other Russian competitors.

"It's a first step," Matthieu Reeb, secretary-general of the court, told Reuters. "There's now potentially a way to get through," he said, adding "we can do an appeal in 24 hours, so anything is possible."

In response to evidence of state-sponsored doping in Russia, the IOC had directed sports federations to allow Russian athletes to compete only if they met certain criteria, including a clean doping past. That led to the exclusion of dozens of athletes.

Spokesman Mark Adams told The Associated Press the IOC accepted the court's decision: "We respect CAS and will of course follow their decision."

IOC President Thomas Bach said earlier in the day: "Sometimes we like the decisions, sometimes not, but we always respect them. CAS is the highest court in sport."

One of the athletes who could take advantage of the new ruling is whistle-blower Yulia Stepanova, who, together with her husband, ignited the Russian doping scandal by revealing the extent of Russia's state-sanctioned doping program and cover-ups.

The IOC was widely criticized for issuing a rule that had barred Stepanova from competing in Rio because of past doping suspensions she already served.

Russia has frequently contended that the bans were arbitrary and discriminatory.

Russian Olympic Committee chief Aleksandr Zhukov said it was unfair that Russian sports stars such as double Olympic champion pole-vaulter Yelena Isinbayeva would be forced to watch the games from home while past doping offenders from other countries, including top U.S. runner Justin Gatlin, were able to compete.

The arbitration court's ruling frees four-times breaststroke world champion Yulia Yefimova as well as rowers Anastasia Karabelshikova and Ivan Podshivalov to join the Games.

Yefimova had been disqualified from competing by swimming governing body FINA because of her previous suspension between October 2013 and February 2015 after testing positive for an anabolic steroid.

Karabelshikova and Podshivalov argued that they should be allowed to compete given they had already served their doping suspensions. The athletes are all expected to get final clearances from their sport federations in light of the court ruling vindicating them.