Russian opposition leader Alexei Navalny, embraces his wife Yulia, as he was released in a courtroom in Kirov, Russia on Friday, July 19, 2013. A Russian court on Friday released Navalny from custody less than 24 hours after he was convicted of embezzlement and sentenced to five years in prison. (Evgeny Feldman/AP)

Alexei Navalny, the blogging scourge of corrupt Russian officials, may have been led off in handcuffs Thursday after being sentenced to five years in prison on dubious charges, but it turns out the charismatic protest leader still had some clout.

Somebody powerful must have decided that Navalny was more valuable — or less dangerous — as a free man than incarcerated.

So prosecutors in the city of Kirov went to court and told a judge he should be released until his appeals can be heard. Even though prominent lawyers here said such a step was unprecedented, Russian judges tend to be receptive to prosecutors’ requests. And on Friday, Navalny walked free — for now.

It was a sharp turnaround in mood, especially for his supporters.

“We understand that what’s happened now is a unique phenomenon in the Russian judiciary,” Navalny said after he was released. “I want to hug you all. We understand that these weird moments when everybody is sad and then happy, well, these moments will come again very soon.”

Genri Reznik, head of the Moscow bar association, told the Interfax news agency that he had never seen a development like it.

Navalny attributed his release to the protests that erupted Thursday night in Moscow and nearly two dozen other cities after his sentencing. Some analysts debated whether it is a sign of conflict between liberals and hard-liners in the Kremlin. But another explanation is the one the prosecutors themselves gave in court: Navalny is running for mayor of Moscow and should be allowed to get out and meet the voters.

The election is in September, and the people who run the city very much want Navalny on the ballot. If he is defeated by the incumbent, Sergei Sobyanin, an appointee of President Vladi­mir Putin’s who now hopes to win an open election, it would demonstrate the limits of the opposition’s appeal and give Sobyanin the imprimatur of the electorate.

And Sobyanin almost certainly will win, because Navalny’s base is intense but narrow — and because the immense resources of the ruling United Russia party, much of the city apparatus and all of the television news broadcasts will be at Sobyanin’s disposal.

Navalny may have gotten out of jail free because his close associate Leonid Volkov played the mayoral card Thursday, saying that Navalny would pull out of the race if he was kept behind bars.

A few hours later, Navalny was out of custody. Crucially, he continued Friday to be coy about the mayor’s race. Maybe he’ll run, maybe he won’t.

Gleb Pavlovsky, a former top aide to Putin, told Interfax that he is sure Navalny will end up in a penal camp when he is no longer useful at large.

An appeal of a court decision in Russia typically takes about six to eight weeks — which would bring Navalny right up to Moscow’s election day. “If we have two more months to fight, we will fight,” Navalny said.

Putin’s spokesman, Dmitry Peskov, said the president would have no comment on the sentencing and release of a man who has referred to him as a toad. “Court rulings need to be respected,” Peskov said at a briefing. “This is the law.”

Navalny planned to return to Moscow on the overnight train, arriving at 9:43 a.m. Saturday. His lawyer told Russian media that under the terms of his release, Navalny must remain in Moscow.

He and a co-defendant, Pyotr Ofitserov, were convicted of stealing nearly $500,000 in a timber deal that Navalny arranged in 2009, when he was an aide to the governor of the Kirov region. The charges were widely viewed as implausible and intended to remove Navalny from the political scene. Ofitserov was also freed Friday.

Judge Sergei Blinov sentenced Navalny to five years and Ofitserov to four, ordering that they be taken into immediate custody, which shocked the courtroom full of supporters.

Thousands thronged sidewalks in the heart of Moscow Thursday evening in an unauthorized last-minute rally. Red Square and nearby Manezhnaya Square were closed off. The police said Friday morning that they had detained 200 people, including some who climbed up to the second-floor windows of the building housing the State Duma, the lower house of parliament.

When Navalny left the courthouse Friday morning, jubilant supporters greeted him with platters of blini, Russian pancakes, in a dig at the judge’s name.