A Russian court on Friday unexpectedly freed protest leader Alexei Navalny pending his appeal against a five-year sentence for embezzlement, as his conviction threatened to further strain relations between the Kremlin and the West.
The judge in the northern city of Kirov ruled that keeping President Vladimir Putin's top opponent in custody would deprive Navalny of his right to stand in Moscow's mayoral election on September 8.
The new ruling came as Navalny's conviction, which remains in place, drew widespread condemnation with US President Barack Obama reportedly "rethinking" a planned trip to Moscow in September.
"What happened now is a completely unique phenomenon in the system of Russian justice," said Navalny, who was immediately set free from the glass-fronted defendants' cage and rushed to embrace his wife Yulia.
A lower court in the city of Kirov 900 kilometres (560 miles) northeast of Moscow had on Thursday sentenced Navalny to five years in a penal colony.
Putin's spokesman Dmitry Peskov however late Friday denied any foul play, saying in the Kremlin's first comment on the verdict that both decisions "were done in accordance with the law" and "must be respected".
Navalny, who is a lawyer by training, was found guilty of defrauding the government in the Kirov region of 16 million rubles ($500,000, 376,000 euros) in a timber deal while acting as an advisor to the local authorities in 2009.
Navalny's co-accused, Pyotr Ofitserov, who was sentenced to four years in prison, was also released on Friday pending his appeal.
The guilty verdict disqualifies Navalny from politics, but the restriction will come into force only if the verdict is upheld on appeal, giving him time to launch a credible campaign for the powerful and visible post of Moscow mayor.
--- 'This has never happened before' ---
Observers say the jailing of a high-profile mayoral candidate during the campaign was a huge embarrassment for the authorities and link the prosecutors' decision to appeal to a possible change of heart by the Kremlin.
Legal experts said the decision to release Navalny was unprecedented and clearly politically motivated. "That has never happened before," lawyer Dmitry Agranovsky told AFP.
Opposition parliament lawmaker Dmitry Gudkov said the authorities' sudden about-face spoke of "a glitch in the system".
"Something went wrong there," he said in his blog.
The Kremlin has remained conspicuously quiet since the initial verdict was delivered Thursday.
The judge in his ruling on Friday said that Navalny's jailing would "limit his right to be elected" and put him at a disadvantage compared to other mayoral candidates.
Navalny said he was not a "pet kitten or puppy" who could be first "kicked out of the elections" and then invited back.
He said he would decide upon his return to Moscow whether to continue his campaign or boycott the polls, where he was due to challenge pro-Putin incumbent Mayor Sergei Sobyanin.
More than 200 people were arrested after thousands rallied near the Kremlin walls in Moscow to protest Navalny's sentencing. All have now been freed.
Police said that 2,500 people took to the streets in the Russian capital, while activists put the turnout at around 10,000, with protests continuing into the early hours of Friday. A similar demonstration also took place in Saint Petersburg.
--- 'A disturbing trend' ---
Navalny, who emerged as a powerful new force in mass protests in 2011-2012, said he wants to run in the next presidential election in 2018. He has vowed to jail Putin if he comes to power.
Observers said the harsh punishment meted out to Navalny was a warning to other dissenters not to challenge Putin.
"He needs to be in jail because that is a lesson to the people of Russia: keep silent," mass-daily Moskovsky Komsomolets said.
The decision to jail the 37-year-old father of two also prompted global concern.
"Navalny's harsh prison sentence is the latest example of a disturbing trend of government actions aimed at suppressing dissent in civil society in Russia," White House spokesman Jay Carney said.
Obama and Putin agreed in June to hold a separate summit on September 3-4, just before the G20 talks, but White House officials have been coy about whether that meeting was still scheduled.
Washington is already furious over the almost month-long stay in a Moscow airport of fugitive US intelligence leaker Edward Snowden, who has now applied for asylum in Russia.
The New York Times reported that unnamed officials said Obama was now "rethinking" the point of having a bilateral summit with Putin. But Kremlin spokesman Dmitry Peskov said Friday the Kremlin was still preparing for Obama's visit to Moscow.