KIROV, Russia — A court’s abrupt decision Friday to release Russia’s most charismatic opposition leader less than a day after handing him a five-year prison sentence appears to reflect confusion in President Vladimir Putin’s inner circle about how to deal with its No. 1 foe.

Even more, it makes clear that the Kremlin is far from a monolith. The surprising about-face involving Alexei Navalny highlights an open rift between factions in Putin’s government that could be as unsettling for the leadership as any opposition figure, experts say.

In an unusual move, prosecutors themselves had requested that Navalny, an anti-corruption blogger and Moscow mayoral candidate, be let go pending appeal just a few hours after he was led out of a courtroom in handcuffs following an embezzlement conviction that was widely seen as unfair.

The decision came as thousands of Navalny’s supporters gathered Thursday around Moscow’s Manezhnaya Square outside the Kremlin for an unsanctioned protest of what they called a politically motivated ruling, chanting “Freedom!” and “Putin is a thief!” in open defiance of the authorities.

Navalny himself credited the protesters with his release, telling reporters Friday that his conviction and sentence “had been vetted by the presidential administration ... but when people came out on Manezhnaya, they rushed to go back on that decision.”

Analysts saw Navalny’s sudden release as likely reflecting arguments within the Kremlin about how to respond to his popularity. He has earned rock-star status among his urban middle-class supporters, even if he has little influence among everyday Russians.

They also saw the move as an attempt to lend legitimacy to the Sept. 8 mayoral vote widely expected to be won by a Kremlin-backed incumbent who resigned last month, forcing a snap election that would make challengers scramble to organize their campaigns.

While the leadership of Russia’s law-enforcement agencies, referred to as “siloviki,” favor nipping the opposition in the bud, other Putin lieutenants promote a more subtle approach to dissent, said Alexei Makarkin, an analyst with the Moscow-based Center for Political Technologies, an independent think-tank.

“Siloviki believe that the opposition must be destroyed,” Makarkin told The Associated Press. “And people in charge of policymaking think that the radical opposition poses no immediate threat and could be allowed to take part in elections, giving them legitimacy.

“These two approaches have led to contradictory decisions made almost simultaneously, and, in the end, those who wanted to legitimize elections prevailed,” he added.

Navalny was a driving force behind a series of massive demonstrations in Moscow against Putin’s re-election to a third presidential term in March 2012.

But Navalny’s popularity outside of urban centers has remained negligible, and a recent opinion survey by the respected independent Levada Center showed that even in Moscow, he has the support of only about 5 percent of respondents.

Navalny said it’s “impossible to predict” whether the move to set him free could raise the chances of his acquittal on appeal. He also said he has not yet decided whether to continue his mayoral campaign.

“I’m not some kitten or a puppy that can be thrown out of an election, say, ‘You’re not running’ and later say, ‘Yes, let’s get him back in.’ I will get back to Moscow and we will talk it over with my election headquarters,” he said.

Incumbent Sergei Sobyanin, who is relatively popular thanks to lavish efforts to spruce up the capital, is widely expected to win the race easily. After rising through the Siberian political ranks, he became Putin’s chief of staff before being named Moscow’s mayor, cementing Kremlin control over the city’s political and business interests.

He was the one who persuaded Putin to release Navalny, said Stanislav Belkovsky, a well-connected political strategist who once advised the Kremlin. The rally of several thousand who defied a ban on unsanctioned protests in support of Navalny may have strengthened Sobyanin’s hand in arguments with his Kremlin opponents.

“Sobyanin needs Navalny to make the mayoral elections look legitimate,” Belkovsky told the AP. “He suffers from a provincial complex, and he wants to prove to Moscow’s residents that his election victory is honest.”

Belkovsky predicted that Navalny could win between 15 percent and 20 percent of the vote, but would likely be sent to serve his sentence after the election. The about-face reflects growing chaos at the top, he said.

The confusion apparently resulted from law-enforcement agencies winning Putin’s approval for a five-year prison term just as Sobyanin was lobbying for a delayed sentence, Belkovsky said. The courts are widely considered to be at Putin’s disposal.

“They won the approval for two alternative decisions, so they ended up with that compromise: Navalny gets his five-year sentence but walks free until the election,” Belkovsky said.

He likened the confusion to the political infighting that engulfed the Kremlin in the waning years of the Soviet Union under Mikhail Gorbachev.

“The government looks increasingly unbalanced,” he said. “The system is destabilizing itself from within. Its prestige has suffered a heavy blow.”

Gleb Pavlovsky, a one-time Kremlin political consultant, also attributed the about-face to Kremlin infighting.

“It’s a war of groups pursuing different strategies,” Pavlovsky was quoted as saying by the Interfax news agency, adding that one group wants the mayoral election to be held “with the maximum legitimacy” while another one wants to keep Navalny in jail.

He said that Navalny has aptly used rifts in the Kremlin to raise his profile. “He stepped into the field where a fight is going on, and he’s using it in his interests,” Pavlovsky said.

Asked if Navalny could be pardoned, Putin spokesman Dmitry Peskov said in remarks carried by Russian news agencies that he would have to plead guilty first. He refused to comment on the verdict and Navalny’s release from custody.

Outside court, Navalny was greeted by his supporters, with one of them offering him blini — Russian pancakes — a sarcastic play on the name of the judge who sentenced him, Sergei Blinov.

The unsanctioned protest in Moscow looked relatively small compared with the massive anti-Putin demonstrations that attracted more than 100,000 in fall 2011 and at the beginning of 2012. But unlike those protests, which were allowed by the authorities, Thursday’s participants braved the threat of heavy fines and prison sentences.

The rally briefly blocked traffic on a busy Moscow street as demonstrators shouted, “This city is ours!” More than 200 people were briefly detained, and about a half of them are expected to face fines.

More than 50 people also were detained briefly in St. Petersburg, and smaller rallies were held in several other cities Thursday.

Navalny was found guilty of heading a group that embezzled 16 million rubles ($500,000) worth of timber from the state-owned company Kirovles in 2009.

The charges against Navalny date back to when he worked as an unpaid adviser to the provincial governor in Kirov, 760 kilometers (470 miles) east of Moscow.

The defense said co-defendant Pyotr Ofitserov’s company bought the timber from Kirovles for 14 million rubles and sold it for 16 million rubles in a regular commercial deal. Navalny’s lawyers presented invoices proving the transactions.

Sentencing Navalny was the latest move in a multipronged crackdown on dissent that followed Putin’s inauguration, including arrests of opposition activists and repressive legislation that sharply increased fines for participants in unsanctioned protests and imposed tough restrictions on nongovernment organizations.