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 the 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 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 upcoming 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 said. “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 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.

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 said. “He suffers from a provincial complex, and he wants to prove to Moscow’s residents that his election victory is honest.”