Russian opposition leader Alexei Navalny has been freed one day after being jailed for five years on embezzlement charges he claimed were politically motivated.
The twist came after thousands of demonstrators took to the streets to protest against the guilty verdict.
Navalny, a vocal critic of President Vladimir Putin, was temporarily released on bail pending an appeal by a Kirov court on the grounds that his custodial sentence would have prevented him running for the Moscow mayoral elections in the autumn.
As the ruling releasing him was handed down, a smiling Navalny, 37, emerged from the caged-off defendants' section of the courtroom and thanked supporters.
Only 24 hours earlier, images of the handcuffed Navalny being escorted away by court bailiffs were broadcast around the world, triggering criticism from foreign governments and huge protests in Russia.
Ten thousand people flocked to Moscow's Manege Square chanting "Freedom!" and "Putin out!" About 200 demonstrators were reportedly held overnight.
"The decision to sentence him for five years has highlighted once again the concerns felt by many about the selective application of the rule of law in Russia," said Foreign Secretary William Hague.
Navalny was found guilty of participating in the embezzlement of 16 million roubles (£300,000) worth of timber from a state-owned company while working as an adviser for the Kirov regional government four years ago.
The anti-corruption blogger, who organised the biggest-ever protests against Putin, suggested that the president had ordered the trial to silence him.
Navalny had publicised online details of the private financial affairs of many Russian politicians close to the president, and famously described Putin's United Russia party as a group of "crooks and thieves".
Prior to his conviction, Navalny's lawyers claimed there was no evidence against him and argued that many witnesses called by the defence were not allowed to appear.
Anaylysts said that the jail sentence risked turning Navalny into a martyr.
Navalny's co-accused, Pyotr Ofitserov, has also been released on bail.