Peru captain Paolo Guerrero has been cleared to play at the World Cup by a Swiss supreme court judge despite his ban for doping, in a career-defining legal victory ahead of the tournament in Russia.

Switzerland's supreme court on Thursday granted an interim order to freeze Guerrero's 14-month ban for a positive test for cocaine metabolites at a World Cup qualifier against Argentina last October, which he said was accidentally consumed in tea.

"As a result, Paolo Guerrero can take part in the next World Cup," the federal court said, noting the tournament could be "without any doubt the crowning glory of his career."

The judge, Christina Kiss, took into account that, at 34, Guerrero should not miss his first opportunity to play at the World Cup.

"This decision does justice, at least partially, and I'm grateful to the Swiss court,'' said Guerrero, who has not formally been cleared of doping and could yet serve the remainder of his ban.

Guerrero's urgent request to the federal court was backed by Peru's government and a wave of emotional support at home from fans believing he is key to the nation's first World Cup appearance in 36 years.

"There are no limits,'' said Peru's all-time leading scorer, who previously played for Bayern Munich. "There are no impossible dreams, as it has been proved that when Peruvians are united, everything is possible."

The court noted that FIFA, which first banned Guerrero, and the World Anti-Doping Agency, which appealed to the Court of Arbitration for Sport for a longer ban, did not oppose him playing in Russia next month.

Kiss wrote in an eight-page judgment how Guerrero benefited from a "rare surge of solidarity" to support his case. That included a letter signed by captains of Peru's three World Cup opponents -- France, Denmark and Australia -- urging he be allowed to play.

She also noted a possible negative effect on Guerrero's teammates of being deprived of their "emblematic" captain.

Paolo Guerrero EPA/German Falcon

The interim ruling puts the ban imposed by CAS on hold until full consideration of the case at a later date in federal court.

The verdict came four days ahead of FIFA's Monday deadline for Peru to finalize their 23-man World Cup squad.

After testing positive for a metabolite of cocaine, Guerrero argued at two FIFA hearings and his appeal to CAS that the stimulant did not offer chemical help to his performance.

The federal judge agreed with the CAS panel, which also accepted the player's arguments of not being significantly at fault for the positive test.

However, the CAS judges increased the ban from six to 14 months, upholding a counter-appeal by WADA. The sports court decided a ban through January 2019 was an "appropriate sanction ... in light of Mr. Guerrero's degree of fault."

Guerrero's original ban by FIFA expired in early May, in the same week that his appeal was heard at CAS. He then returned to play for Brazilian club Flamengo.

Earlier on Thursday, CAS -- which is based less than a kilometre from the federal court in Lausanne -- issued a statement saying it would not object if Guerrero was cleared to play in Russia.

Guerrero had the right to a supreme court appeal because CAS is under the jurisdiction of Swiss civil law. Federal judges can intervene if they suspect abuse of legal process.

At the World Cup, Peru open against Denmark on June 16 in Saransk.

Peru soccer federation president Edwin Oviedo said the ruling was "a nice way to unite the whole country with an announcement that makes all Peruvians happy."

Guerrero joined up with his Peru teammates and posted a video on Facebook saluting them with the message: ""Happy to be with them!I love you Peru."

He also wrote a message saying that "everything is possible" when his country comes together.

"A Swiss Federal Tribunal has frozen the unjust ban given against me and as a consequence has allowed me to join my national team and take part in the World Cup in Russia as their captain," Guerrero said.

"This decision does justice, at least partially, and I'm grateful to the Swiss tribunal.

"My battle continues and my lawyers will take care of that. I join my national team and along with my teammates, I pledge to give my all to give new and bigger joys for our country.

"There are no limits. There are no impossible dreams because it's proven that when Peruvians come together, everything is possible."

Guerrero went on to thank those who stood by him, including FIFA president Gianni Infantino.

"This would not have been possible without the support of the Peruvian Football Federation and in particular its president Mr. Edwin Oviedo, who remained by my side, in Switzerland, and every day until we got this favorable outcome," he said.

"Equally invaluable has been the support of each and everyone of my national teammates. They have transmitted the necessary strength to overcome this difficult time but this does not surprise me as they behave like a family, which is what we are.

"Finally, my gratitude to FIFA president Gianni Infantino, to the captains of Australia, Denmark and France, to FIFPRo, my professional colleagues of other national teams and the so many people, that in one way or another have been useful for this decision to come about."

Peru take on Saudi Arabia on Sunday in a World Cup warm-up in Altach, Austria.