China's three-time Olympic champion Sun Yang has been banned for eight years for missing a doping test in September 2018.
The 28-year-old was initially cleared of wrongdoing by Fina, the swimming federation, in January 2019.
Following an appeal by the World Anti-Doping Agency (Wada) to the Court of Arbitration for Sport (Cas), the decision has been overturned.
An eight-year ban was imposed on Sun because this was his second offence.
He had served a three-month suspension in 2014 for taking prohibited stimulant Trimetazidine.
Sun told China's Xinhua news agency that he plans to appeal against the decision.
He said: "This is unfair. I firmly believe in my innocence."
Fina said it would implement the decision "notwithstanding any further legal action and as directed".
Cas said its decision can be challenged before the Swiss Federal Tribunal within 30 days.
Sun had told an appeal hearing in November that he missed a test because testers failed to prove their identity when they arrived at his home.
He also denied a vial containing his blood samples was smashed with a hammer.
Cas said: "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 with the ISTI (international standard for testing and investigations).
"As the Cas panel noted, it is one thing, having provided a blood sample, to question the accreditation of the testing personnel while keeping the intact samples in the possession of the testing authorities; it is quite another thing, after lengthy exchanges and warnings as to the consequences, to act in such a way that results in destroying the sample containers, thereby eliminating any chance of testing the sample at a later stage."
Wada welcomed the ruling, and added that it was "satisfied that justice in this case has been rendered".
At the 2019 World Aquatics Championships in July, Sun won gold in the 200m freestyle but Britain's Duncan Scott refused to share the podium with him.
Australian Mack Horton took a similar stance after the 400m freestyle, years after accusing him of being a "drug cheat".
Scott said on Friday: "I fully respect and support the decision that has been made.
"I believe in clean sport and a level playing field for all athletes and I trust in Cas and Wada to uphold these values."
Sun's results prior to, during and after the championships will stand because he has not tested positive for doping.
He has won 11 world titles since 2011, including two golds at last year's event in Gwangju, South Korea.
When Fina originally cleared him, it said that testers had breached several rules, including failing to produce authorisation letters and a nursing licence. Sun was subsequently issued with a warning.
The Cas appeal was heard in public. The only previous time that had happened was in 1999 when Ireland's triple Olympic swimming champion Michelle Smith de Bruin failed with her appeal against a four-year ban for tampering with an anti-doping sample.
'You're disrespecting your country' - reaction
Adam Peaty, British Olympic 100m breaststroke champion: "Very good. For anyone that's been banned once, potentially it's a mistake.
"You're looking at it twice - you're a fool. I believe that you're disrespecting the sport, you're disrespecting yourself and you're disrespecting your country."
Mack Horton, Australian swimmer who refused to share a podium with Sun: "My stance has always been for clean sport. It is not, and never will be about individuals or nations. Today's outcome does not change my stance."
Lizzie Simmonds, British two-time Olympian & former European champion: "I once called this man the Harry Houdini of doping control, but it seems that justice has finally been served.
"Imagine there will be a few very relieved freestylers waking up across the world.
"Given the damning length of this sentence, it seems inconceivable that he originally just received a slap on the wrist from Fina.
"A strong message to those who cheat, but I hope an even stronger message to those who seek to protect bureaucratic harmony over sporting integrity."
James Guy, British four-time world swimming champion: "The truth always comes out."
Dan Roan, BBC sports editor
This is a hugely significant case for sport, and one that will lead to serious questions about the judgement and credibility of Fina, which will now come under pressure to establish an integrity unit, similar to those created for athletics and cycling.
Swimming's world governing body caused dismay among many in the sport when it cleared Sun last year.
That decision, combined with Sun's mega-stardom in the sporting superpower of China, his infamy after already serving a doping suspension in 2014, and the dramatic symbolism of a case in which a blood vial was smashed with a hammer, meant an especially bitter controversy - the antipathy with some of his rivals marring last year's World Championships.
The severity of the eight-year ban (which almost certainly ends Sun's career) will be celebrated by many in swimming and beyond as a sign of the sport getting tougher on doping, and perhaps restore some faith in the anti-doping system.
But it will no doubt provoke outrage in China, and may reinforce the sense both there and in places like Russia (which is appealing over its Olympic ban) that Cas is biased against countries in the east. Expect further appeals (to the Swiss Federal Tribunal) and recriminations.