MOSCOW -- The ground rules were set in the moments before the mayor, Sergei S. Sobyanin, arrived on the Kremlin embankment of the Moscow River accompanied by Patriarch Kirill I, the leader of the Russian Orthodox Church.
There would be no questions -- and no photographs of the men until they stood perfectly positioned against the backdrop of the pink and white bell tower of the Church of Sophia, Wisdom of God, recently restored thanks to the munificence of the mayor's office.
"Just imagine that there is a glass wall between us and them," a mayoral aide, Aleksandr Gerasimov, explained.
That has, in truth, been the case here ever since President Vladimir V. Putin came to power and proceeded to orchestrate elections in which the Kremlin's favored candidates remained far removed from the people who nominally elect them. As voters go to the polls on Sunday in Moscow, Mr. Sobyanin has played his part, eschewing most overt political campaigning, as Mr. Putin has before. The election itself, however, has not followed the usual script.
The improbable campaign of Aleksei A. Navalny, the corruption-fighting activist, has exposed disarray in the political system Mr. Putin has constructed. Beginning with Mr. Navalny's conviction for embezzlement and prompt release on appeal in July, the Kremlin's response to his campaign has been contradictory and at times confused, revealing what many view as growing schisms among Mr. Putin's closest circle of advisers.
"The splits and differences that have existed in these circles forever have become arguably more tense," said Maria Lipman, a researcher at the Carnegie Moscow Center, "and they have played out publicly more frequently than before."
Mr. Navalny, 37, and any ads on his behalf have been barred from national television, while he and his supporters have faced harassment and threats of new criminal investigations, including a police raid of an apartment of Navalny supporters that was orchestrated by another candidate considered loyal to the Kremlin.
At the same time, Mr. Navalny has openly campaigned before larger and larger crowds. He modeled his efforts, he said, on those he learned watching the HBO series "The Wire," speaking to voters in a way that has not been seen since the early years of democracy after the Soviet Union's collapse.
That has tested the limits of the authorities' tolerance, provoking responses that seem tentative and uncertain.
When a recent rally drew thousands of supporters, the police promptly detained Mr. Navalny, only to release him, he said, because they had no orders telling them what do next.
"It was completely unclear why the police came to take me from the stage and then half an hour later let me go, saying they had not detained me at all," Mr. Navalny said in an interview, describing a comic odyssey in which he was driven in circles in a police van. "Nobody understands that logic."
Mr. Sobyanin, a former governor from Siberia and a Kremlin aide who was appointed mayor in 2010, is almost certain to win Sunday's vote, though Mr. Navalny remains hopeful that either he or one of the other five candidates challenging Mr. Sobyanin can draw enough votes to force a runoff against the mayor two weeks later.
"During a second round, everything will change," Mr. Navalny said. "It's obvious that that would destroy their general portrayal that they're so big and we're so small."
Mr. Sobyanin's campaign manager, Lyudmila I. Shvetsova, said the mayor welcomed a fair election, acknowledging indirectly that previous elections had been marred by machinations and accusations of fraud. Mr. Sobyanin himself has repeatedly said that Mr. Navalny should remain in the race, even as unproven accusations swirled that Mr. Navalny owned property abroad and that his campaign had committed other violations that would, if true, have disqualified him.
Mr. Sobyanin has done so even as Mr. Navalny has continued the anticorruption crusade that made him famous, exposing documents suggesting that Mr. Sobyanin's 16-year-old daughter has a $3 million apartment in Moscow registered in her name. (Mr. Sobyanin's campaign claimed the acquisition was lawful.)
That has led to speculation that Mr. Sobyanin is among the Putin advisers who have advocated a loosening of the repressive political system Mr. Putin has erected to ensure that only Kremlin-approved candidates win elections. The argument is that the Kremlin is willing to risk more direct political challenges, if only to reinforce Mr. Sobyanin's legitimacy as an elected, not appointed, mayor.
Mr. Sobyanin, 55, is relatively new to Mr. Putin's close circle of aides, though he previously served as a deputy prime minister and as head of the presidential administration under his successor and protégé, Dmitri A. Medvedev. He began his political career as a fledging democrat in the first (and last) elected institution in the Soviet Union, running and losing a race for a seat in the Congress of People's Deputies in 1990 representing the ethnic region of Khanty-Mansi.
In an interview in the magazine Itogi, Mr. Sobyanin portrayed himself then, intentionally or not, as an upstart very much like Mr. Navalny today. "I walked a lot around the courtyards and apartment entrances, met with people, spoke, explained my program," he said. "It was received well. They said that they would certainly support me. But the big boss, who was also running in the elections, promised the residents of the district that he would put telephones in every apartment."
He went on to win election as governor of the Tyumen region in 2001, though he was reappointed by Mr. Putin four years later after elections for regional posts were abolished as part of the Kremlin's imposition of control. Mr. Medvedev, who served four years as president before Mr. Putin returned to the post, restored the regional elections last year, including that for mayor of Moscow.
Mr. Sobyanin is a bland politician compared with his flamboyant predecessor, Yuri M. Luzhkov, who was dismissed in 2010, but he has been credited with at least cosmetic improvements in municipal life, like the renovation of Gorky Park.
While the four other challengers represent established parties, Mr. Navalny has emerged as the most competitive. His grass-roots strategy and war on corruption have tapped into popular discontent, especially among young, educated and relatively well-off Muscovites. He has recruited 14,000 volunteers and openly held fund-raisers, including with businessmen, to pay for the leaflets, posters and banners that have appeared across the city.
Mr. Sobyanin has avoided similar efforts, relying on lavish coverage on state television channels of his duties as the incumbent, like the restoration of the Sophia bell tower (which, to be exact, began during Mr. Luzhkov's mayoralty). He refused to participate in the debates, which were shown on little-watched cable channels, and he postponed a call-in show, perhaps because when he sent proxies to a town-hall-style meeting, they encountered angry constituents.
Mr. Putin's Kremlin remains so opaque that few know exactly what has motivated the comparative openness of the election. Skeptics note that the appeal of Mr. Navalny's conviction could come at any moment, before or after the election, sending him to prison for five years and statutorily removing him from public life.
They have also pointed to a recent meeting with political strategists organized by a senior Kremlin aide, Vyacheslav V. Volodin. Although it was held behind closed doors, those who attended said Mr. Volodin advocated a more democratic process that would avert the mass protests that greeted the 2011 parliamentary elections and Mr. Putin's re-election a year later. At the same time, though, he made it clear that no real opposition leader would be allowed to emerge. His model was reportedly called "competition without change."
Sergei A. Markov, a political strategist with ties to the Kremlin who was at the meeting, said that the strategy would allow Mr. Sobyanin to demonstrate that he has legitimate political support, something that would not happen if he ran without significant opposition. Even so, he said, Mr. Putin and others around him fear that Mr. Navalny represents the forces of a potential "orange revolution" like the one that overturned a fraudulent election in Ukraine in 2004.
"These people don't believe that Navalny wants democracy," Mr. Markov said. "They believe he wants to destroy Russia."
Mr. Putin is not known to have ever publicly uttered Mr. Navalny's name. When asked directly about Mr. Navalny's conviction at a meeting with young people at an annual summer camp near Lake Seliger, Mr. Putin suggested that his candidacy would be a test of his political viability.
"Everyone needs to learn to abide by the law, not just make a lot of noise and shout, 'Stop thief!' " he said, insisting he had not followed the trial, the most prominent against a Kremlin opponent since the jailing of the former oil tycoon Mikhail B. Khodorkovsky a decade ago. "Rather, they need to put forward some sort of platform and promote it in a reasonable way without aggressiveness."
Then he added: "The public must decide what it all means and whether this or that individual deserves their trust. We will see what happens during the political campaign."
Andrew Roth and Noah Sneider contributed reporting.
This article originally appeared in The New York Times.