Last updated on .From the section Winter Olympics

The Olympic athletes from Russia team paraded under the Olympic flag at the opening ceremony, and will do so at the closing ceremony at 11:00 GMT

Russia's Olympic ban will be lifted if there are no more doping violations from their athletes at Pyeongchang 2018, the International Olympic Committee has ruled.

However, the IOC did not allow Russian athletes to parade under their own flag at the closing ceremony.

Russia was banned because of state-sponsored doping at Sochi 2014.

A team of 168 competed in South Korea as neutral Olympic athletes from Russia (OAR) but two failed drugs tests.

Alexander Krushelnitsky won bronze in the mixed curling but was stripped of his medal after being found guilty of doping while Nadezhda Sergeeva, who competed in bobsleigh, was banned on Saturday.

IOC president Thomas Bach said the failed tests were "very disappointing and prevented the IOC from considering lifting the ban for the closing ceremony".

But referring to the two positive tests, he added: "There is no evidence of systemic doping and no evidence of the involvement of the Russian Olympic Committee in these cases."

The decisions on Russia's ban and the closing ceremony were carried unanimously at a meeting of the IOC, following recommendations from its executive board.

The session heard from Nicole Hoevertsz, the head of an implementation group that reported to the IOC on the OAR delegation's "exemplary" behaviour in Pyeongchang.

"We have to draw a line and look towards the future," Hoevertsz said.

"We need to bring this story to an end and look forward. It is never going to be business as usual in sport again or in Russia."

When the IOC announced Russia's ban in December, Bach said the hosts' doping at the Sochi 2014 Games "was an unprecedented attack on the integrity of the Olympic Games and sport".

Only athletes who proved they were clean were able to compete in Pyeongchang for OAR, whose team was the third largest at the Games and won 17 medals, including two golds.

Why was Russia's Olympic Committee banned?

Grigory Rodchenkov speaks to BBC sports editor Dan Roan in February 2018

This entire investigation was instigated by whistleblowing doctor Grigory Rodchenkov, who was director of Russia's anti-doping laboratory during Sochi 2014.

He alleged the country ran a systematic programme of doping and claimed he had created substances to enhance athletes' performances and switched urine samples to avoid detection.

The World Anti-Doping Agency (Wada) enlisted the services of Canadian law professor and sports lawyer Dr Richard McLaren to look into the allegations.

The McLaren report concluded 1,000 athletes across 30 sports benefited from the doping programme between 2012 and 2015.

Wada obtained what it said was a Russian laboratory database which it felt corroborated McLaren's conclusions, while retesting of Russian athletes' samples resulted in a host of retrospective bans and stripping of medals.

Last week, Rodchenkov told BBC Sport that the IOC faced "the most important moment in its history" over whether to allow Russian athletes to parade with their national flag at Sunday's closing ceremony.

Letting them do so would be the IOC's "worst decision", he said.

Reacting to the IOC's decisions on Russia, Rodchenkov's lawyer, Jim Walden, said in a statement: "Thomas Bach was a drowning man, but finally cooler heads within the IOC threw him a life preserver.

"Yet, in the decision, the IOC had the gall to claim Russia 'respected' its decision on 5 December to institute the suspension. This, despite Russia's continued retaliation against the IOC's main witness, Dr Rodchenkov, and Russia's litany of further transgressions, including denial and obstruction toward the IOC and World Anti-Doping Agency. The acrimony caused by Bach's mismanagement should be his undoing."

How has Russia reacted?

The Russian Olympic Committee (ROC) says it hopes to be back in the Olympic fold "in the next few days" and welcomed the IOC's decision.

"In light of the situation, we consider that the restoration of the rights of the ROC and all Russian athletes will be the main result of the Olympic Games that are ending today," it added.

However, some athletes were said to be disappointed that they would not be able to march under their national flag at the closing ceremony.

"Some athletes stayed behind later with the hope that they would be walking under the Russian flag. I've heard athletes say that they were staying just because they wanted to walk with the flag and in our uniform," Elena Valbe, president of the Russian cross-country skiing federation, said.

Analysis

BBC sports news correspondent Alex Capstick in Pyeongchang

In the end it looks like a compromise. Russia didn't get to march under its own flag at the closing ceremony but the return of its Olympic status could be imminent.

Allegations of a huge state-sponsored doping programme meant Russia had been banned from the Games, although some if its athletes who were deemed to be clean were controversially allowed to take part under a neutral banner.

The fact that two of these competitors were then caught doping in Pyeongchang meant the IOC decided not to lift the suspension immediately.

But Russia will soon be welcomed back into the fold as long as none of its other athletes are found to have broken drug rules.