China's most famous swimmer got a second chance to avoid a doping ban and compete at the Tokyo Olympics, and lost.

This time, however, Sun Yang's ban is less likely to end the three-time Olympic champion's career.

A new panel of judges at the Court of Arbitration for Sport banned the 29-year-old Sun on Tuesday for 4 years, 3 months — about half the eight-year sanction handed down after the first trial in 2019.

CLICK HERE FOR MORE SPORTS COVERAGE ON foxnews.1eye.us

The verdict ended Sun's hopes of defending his Olympic title in the 200-meter freestyle in Tokyo next month. But the ban was backdated to February 2020, meaning Sun could return for the 2024 Paris Olympics when he would be 32.

The judges found Sun "to have acted recklessly" when he refused to let anti-doping officials leave his home with a sample of his blood. The formal charges were for refusing to give a sample and tampering with a doping control.

Sun denied wrongdoing and his original eight-year ban imposed last year was overturned on appeal to Switzerland’s supreme court, which ordered a fresh trial.

Federal judges ruled the first guilty verdict was tainted because the chairman of that three-person panel at CAS showed anti-Chinese bias in social media comments.

The retrial was heard by different judges by video over three days last month and fast-tracked ahead of the Tokyo Olympics, which open on July 23.

For the retrial, Sun's Geneva-based legal team was aided by lawyers who successfully represented Russia's anti-doping agency and athletes in previous CAS hearings about doping violations.

Sun's case centered on a failed attempt to take blood and urine from the swimmer by a sample collection team who made an unannounced visit to his home in China in September 2018.

It turned confrontational after midnight when he questioned the officials' credentials. It led to Sun’s entourage ordering a security guard to smash the casing of a blood vial with a hammer so that it would not be valid for testing.

The World Anti-Doping Agency appealed to CAS when a tribunal appointed by swimming governing body FINA only warned the Olympic champion about his conduct.

WADA requested a ban of two-to-eight years for a second doping conviction. Sun served a three-month ban in 2014 imposed by Chinese authorities after testing positive for a stimulant that was banned at the time. The ban was not announced until after it ended.

WADA welcomed the latest CAS ruling on Tuesday, noting that its concerns about FINA's inconsistent interpretation of anti-doping rules were upheld again.

"The decision by the Swiss Federal Tribunal to set aside the (original) CAS award was limited to a challenge made against the chair of the CAS panel and had nothing to do with the substance of this case," WADA director general Olivier Niggli said.

Sun’s eight-year ban had been imposed after a rare CAS hearing held in open court and streamed live online. That was requested by the athlete and lasted more than 10 hours in November 2019 at a special court session in Montreux, Switzerland.

A change this year to FINA's rules in anti-doping cases meant the eight-year ban for a second offense could be reduced. The amendment "represents a newly flexible approach," the court said.

The 6-foot-7 (2-meter) Sun was the first Chinese swimmer to win Olympic gold, at the 2012 London Games, and has long been a polarizing figure in the pool.

Rivals branded him a cheater at the 2016 Rio de Janeiro Olympics, and two competitors refused to stand with him on medal podiums at the 2019 world championships, where he competed despite the pending appeal brought by WADA.

Sun won a total of 11 gold medals in five straight world championships from 2011 to 2019, at each freestyle distance from 200 to 1,500.

CLICK HERE TO GET THE FOX NEWS APP

FINA officials have been criticized during Sun’s career for protecting the sport’s biggest star in a key commercial market.

After winning Olympic gold in Rio in a hostile atmosphere, Sun was hugged poolside by Cornel Marculescu, the long-time FINA executive director who retired in March. Sun said Marculescu had watched over him "like a grandfather."

FINA issued a brief statement Tuesday that it "acknowledges" the CAS ruling, which was not yet published in detail.

"FINA remains committed to the protection of all clean aquatics athletes worldwide," the Switzerland-based governing body said.