By Karolos Grohmann

(Reuters) - Yulia Stepanova, the key whistleblower in the Russian doping scandal that almost led to her country being completely excluded from the Rio de Janeiro Games, will miss the Olympics after the runner was controversially ruled out due to her doping past.

The International Olympic Committee (IOC) invited the middle-distance athlete and her husband to attend next month's Games as guests but denied her a competitive spot in Rio, arguing her doping-tainted past made her ineligible.

Stepanova, who provided evidence of doping in a series of German broadcaster ARD documentaries, has fled Russia and is living in hiding at an undisclosed location in North America, fearing for her safety.

She was cleared to compete in Rio as a neutral athlete by the International Association of Athletics Federations (IAAF) and received praise for revealing one of the biggest doping scandals in decades.

However, the IOC ruled on Sunday that any Russian athlete with a doping past, including Stepanova, would not be allowed to compete in Rio.

"The executive board have appreciated that she came forward and she and her husband, who also played a very important role, are being invited to the Olympic Games as a guest of the IOC," IOC President Thomas Bach said.

Unfortunately she could not compete due to her doping background, Bach added.

This decision is a controversial one after part of the Olympic Charter blocking sanctioned athletes from future Games, known as the "Osaka rule", was struck down by the Court of Arbitration for Sport (CAS) in 2011.

In making its decision, CAS argued that there could not be a double punishment for already-sanctioned athletes.

"The IOC is taking a risk with this controversial decision but they know that with such limited time, any serious Russian challenge is extremely difficult," an Olympics insider with direct knowledge of the affair, told Reuters on Monday.

"The IOC also knows that the Russian athletes affected by it would have a really good case at CAS."

A similar rule by the British Olympic Association to ban the nation's drugs cheats from Olympic participation for life was also rejected by CAS ahead of the 2012 London Games, allowing sprinter Dwain Chambers to race.

The CAS decision will allow many past doping offenders from around the world, including top U.S. runners Justin Gatlin and LaShawn Merritt, to compete in Rio.

While there will be further discussions on the IOC verdict in the coming weeks, it is unlikely many Russians will take their case to CAS with only 10 days remaining before the Games open on Aug. 5.

"We don't have time enough to do such a thing," Russian Olympic Committee President Alexander Zhukov said on Sunday, ruling out any CAS challenge by his organization and dashing any lingering Olympic hopes for Stepanova.

(Editing by John O'Brien)