Chinese swimmer Sun Yang was banned for eight years on Friday and will miss the 2020 Tokyo Olympics because he broke anti-doping rules in a late-night incident in which a blood sample container was smashed with a hammer.

The Court of Arbitration for Sport found the three-time Olympic champion guilty of refusing to cooperate with sample collectors during a visit to his home in September 2018 that turned confrontational.

In a rare hearing in open court in November, evidence was presented of how a security guard instructed by Sun’s mother broke the casing around a vial of his blood. The swimmer lit the early-hours scene with his mobile phone.

“The athlete failed to establish that he had a compelling justification to destroy his sample collection containers and forego the doping control when, in his opinion, the collection protocol was not in compliance,” the CAS panel of three judges agreed in a unanimous verdict.

TOKYO ORGANIZERS, GOVERNMENT TAKE OFFENSIVE ON VIRUS THREAT

China's greatest ever swimmer, and one of its biggest sports stars, had asked CAS for a public trial.

A 10-hour hearing broadcast on the court’s website showed Sun to be evasive at times under questioning that was hampered by severe translation issues between Chinese and English. The CAS panel’s verdict was delayed until all parties got a verified translation.

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

Rivals branded him a drug cheat at the 2016 Rio de Janeiro Olympics, and two competitors refused to stand with him on medal podiums at the 2019 world championships.

Now banned until February 2028, the 28-year-old Sun cannot defend his 200-meter freestyle title in Tokyo.

TOKYO ORGANIZERS, IOC GOING AHEAD AS PLANNED WITH OLYMPICS

The World Anti-Doping Agency went to CAS after a FINA tribunal only warned Sun. The first ruling was that anti-doping protocol was not followed, making the samples invalid, and cited doubts about credentials shown to him by the sample collection team.

“WADA ... is satisfied that justice in this case has been rendered,” the body's director general Olivier Niggli said in a statement.

Sun can now appeal to Switzerland’s supreme court, but on narrow procedural grounds. His lawyers have already had three federal appeals dismissed on legal process issues.

WADA requested a ban of between two and 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.

That first case led to criticism of FINA for appearing to protect one of the sport’s biggest stars in a key market.

Swimming's governing body said it will make a statement later Friday.

Sun never missed a major event while banned in 2014. He added 200 gold at the 2016 Rio de Janeiro Olympics to the historic 400 and 1,500 titles he took in London four years earlier.

'MIRACLE ON ICE' 40 YEARS AGO WAS SO GREAT, TWO MOVIES WERE MADE ABOUT IT

He won a total of 11 golds in five straight world championships from 2011 to 2019, at each freestyle distance from 200 to 1,500. At three Asian Games from 2010 to 2018, he won nine gold medals.

The court ruled Friday that Sun can retain the two world titles he won in South Korea last July while the WADA appeal case against him was pending.

Days after the 2018 Asian Games, Sun was visited at his home by three officials sent by a Swedish firm to get blood and urine samples from him. International athletes must notify where and when they will be available for one hour each day, and Sun had suggested late on Sept. 4.

When FINA prosecuted Sun following the incident, its tribunal panel in January 2019 merely warned Sun and cited doubts about the officials’ credentials.

Although Sun and his entourage, including his mother, were criticized for their conduct, the FINA panel said the sample mission was void because anti-doping protocol was not followed. Technically, Sun was judged to be not properly notified of needing to give samples.

In the CAS hearing, questioning by judges and WADA’s lawyers revealed skepticism that an experienced athlete could claim to be so unfamiliar with the process and the paperwork.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

FINA and Sun’s legal team failed in pre-trial efforts to remove WADA’s lead prosecutor from the case. They argued there was a conflict of interest because of the lawyer’s previous work with FINA, but Sun’s appeal was dismissed by CAS at an earlier hearing.