Sun Yang, the three-time Olympic swimming champion from China, was suspended from competition for eight years for a drug-testing violation, the Court of Arbitration for Sport ruled on Friday, a decision that will keep him out of the Tokyo Olympics this year and most likely end his career.

Sun, 28, a six-time Olympic medalist and the first Chinese man to win a swimming gold medal at the Games, had been fighting a multiyear battle with the World Anti-Doping Agency to preserve his eligibility in international competition.

WADA brought a complaint against Sun, currently China’s most famous athlete, to the court after swimming’s international governing body declined to penalize him for refusing to cooperate with three antidoping officials who had traveled to his home in China to retrieve blood and urine samples.

During that confrontation in September 2018, Sun argued with the testers and his mother ordered a security guard to break his blood-sample vials with a hammer. Sun declined to submit a urine sample.