The Court of Arbitration for Sport has upheld the ban on Forty-five Russian athletes and two coaches, dismissing their appeal to take part in the Winter Olympics.
The athletes had argued that they had been banned by the International Olympic Committee unfairly after the 2014 doping scandal.
The decision of sport's highest court was announced fewer than nine hours prior to the opening ceremony of the Games, in Pyeongchang, South Korea.
The ruling related to two separate cases, one involving 32 athletes and another involving 15 individuals, 13 of them athletes, two of them coaches.
Some of the athletes had lifetime bans overturned by the IOC last week, leading to a last-minute appeal to take part in this week’s Games. However, CAS concluded the IOC process in banning the athletes from the Olympics was not "discriminatory, arbitrary or unfair" and they had the right to say who was eligible to take part in the Games.
The IOC process "could not be described as a sanction but rather as an eligibility decision," said CAS Secretary General Matthieu Reeb.
The IOC later released a statement that said: "We welcome this decision which supports the fight against doping and brings clarity for all athletes."
The IOC said in December that Russian athletes who proved they were clean would be allowed to compete as neutrals in the Games.
The Olympic Athletes of Russia (OAR) will compete under the Olympic flag and the Olympic anthem will be played at any medal ceremonies they feature in.
The OAR is the third largest delegation at the Games after the United States and Canada, with 168 athletes.
Among the athletes who were hoping to gatecrash the Olympics by forcing an invite through CAS were Victor Ahn and and Elena Nikitina.
South Korea-born Ahn is the most decorated short-track speed skater in Olympic history with six gold medals. He became a Russian citizen to represent the hosts at the Sochi Games.
Skeleton's Nikitina was stripped of her bronze medal from Sochi 2014.
Nikitina told TASS: "I'm very disappointed. I was hoping that CAS would take our side. I need to consult with lawyers."