Russian opposition leader and anti-corruption blogger Alexei Navalny has had a five-year jail sentence lifted but the appeal court upheld his conviction for theft, preventing him from running in future elections.
He was instead given a suspended term after being convicted on embezzlement charges on July 18.
Mr Navalny was released from prison the day after his trial in what some considered a ploy to make the Moscow mayoral race, where he was registered as a candidate, look as competitive as possible.
Mr Navalny got an unexpected 27 per cent against the Kremlin-backed incumbent. His growing public profile has made it increasingly risky for the Kremlin to put him behind bars.
Regardless of his own inability to hold office, Mr Navalny could still prove a vital political force in Russia.
He has vowed to wage an active campaign, even if not a candidate himself, in elections for the Moscow city government in September 2014. His run for Moscow mayor attracted thousands of young volunteers in an unprecedented grassroots campaign effort, and that network could prove a key organizing force in the 2014 race.
The charges against him date back a few years to when he worked as an unpaid adviser to the provincial governor in Kirov. Prosecutors said he was part of a group that in 2009 embezzled 16 million roubles (£311,000) of timber from the state-owned company Kirovles. He has denied the charges.
The defence said that a company run by Pyotr Ofitserov - Mr Navalny's co-defendant who was also given a suspended sentence of five years as well in the appeal - bought the timber in a normal commercial deal.
Mr Navalny, who spent much of the court session tweeting, was characteristically sarcastic and upbeat.
After the judge read out the sentence, he said he had no doubts the decision had been made "personally by Vladimir Putin," and said that "the authorities are doing their utmost to pull me out of the political fight."
The sentence eliminates him from running in any elections in the future, according to a 2012 law that bans anyone with a criminal conviction for serious crimes, even if the sentence is suspended, from political office for life.
That law has been controversial in a country where, according to a 2011 survey by the Moscow-based Centre for Legal and Economic Studies, one in six business people have faced criminal charges. About 120,000 people are serving prison sentences in Russia for economic crimes.
Last week Russia's highest court ruled that parts of the law were unconstitutional, and asked the legislature to amend it so that only those convicted to life sentences would be banned from political office for life.