Russian opposition leader Alexei Navalny speaks to the media outside of his headquarters in Moscow on Monday, Sept. 9, 2013. (Sergei Grits/AP)

Alexei Navalny, the outsider who challenged Russia’s all-powerful political establishment, stood before thousands of cheering supporters Monday night and declared a sweeping victory.

Only hours before, he had been ruled the loser in Moscow’s mayoral election. But as he stood on a stage on an island near the Kremlin, Navalny saw only triumph.

He had been denied billboards and television time. Most newspapers ignored him. President Vladimir Putin refused to speak his name. Over the summer, he was sentenced to five years in prison on theft charges that were widely considered trumped up. The date of the election had been set to give incumbent Sergei Sobyanin, handpicked by the Kremlin, the advantage.

And still Navalny had won 27 percent of the vote, coming within a hair of forcing Sobyanin into a runoff.

“A great opposition has been born in Moscow,” Navalny proclaimed once, then again and again. “When one in three voters in Moscow voted for us, I know that this is a victory.”

Moscow, one observer tweeted, had just had its “I have a dream” moment.

Navalny, a 37-year-old lawyer, came to the election with no campaign experience, little money and a reputation among the Internet-savvy as an effective anti-corruption blogger. Sobyanin had been appointed mayor in 2010, and an election for the post was scheduled for 2015. In June, the election was unexpectedly set for Sept. 8 after Sobyanin resigned and was immediately appointed acting mayor by Putin.

The maneuver was widely described as a way for Sobyanin to acquire the legitimacy of election when he was relatively popular and when other candidates had not had time to prepare.

Turnout in Sunday’s election was an anemic 33 percent. One Navalny volunteer, speaking at the rally Monday night, blamed it partly on a bountiful apple harvest. Many Muscovites were out in the country picking apples from their gardens ahead of the approaching winter, she said.

And many people have grown cynical about elections, especially since a parliamentary vote in December 2011 provoked complaints about widespread fraud. Dissatisfaction with that election led to a winter of vigorous protest, which faltered as leaders were arrested and laws to limit demonstrations were passed.

“We have been longing to stage a victorious rally for such a long time,” Navalny said. “We got really tired of continuously losing for the last 13 to 15 years. I am happy to speak here today in front of you at a rally of victory. Thank you.”

Election monitors said that overall, the mayoral vote had been honest compared with other elections. But with 51.4 percent of the vote, Sobyanin only narrowly avoided a runoff, setting off criticism by Navalny supporters who said they will press election officials for a second round.

Grigory Melkonyants, a leader of the Golos election monitoring movement, said at a news conference that major violations had not been observed, but various complaints were being studied. Among them were allegations that votes cast by the housebound and the hospitalized could have been manipulated.

Leonid Volkov, Navalny’s campaign manager, said that Navalny had managed to pull off the miracle his supporters hoped for when he decided to run. “When 600,000 people voted for us, they said yes, they wanted change in Moscow.”

He said the campaign would press for a runoff. “About 100,000 people voted at home,” he said, “and somehow their votes went to Sobyanin.”

Election monitors, however, remain critical of the advantages that members of the establishment are awarded long before voting day. As the incumbent, Sobyanin basked in lavish television coverage, which highlighted how he was improving the city. Navalny spent much of the summer distracted by his trial, making frequent trips on the overnight train back and forth between Moscow and Kirov, where he was in court two or three days a week.

Sobyanin insisted that the election had been fair. “We passed the election transparency and fairness exam,” he told supporters. “We did everything in our power to help candidates register and did the utmost to prevent vote falsification.”

Navalny supporter Lyubov Tsulayeva, a 48-year-old veterinarian, stood by herself in the crowd, a pleased expression on her face. The votes for Navalny, she said, meant people were finally standing up and demanding better government.

“It’s hard to live like this,” she said. “I’m tired of the lies. There are lies everywhere.”

The authorities have been promising better pay for teachers, doctors and others who earn government salaries, but nothing happens, she said. Her daughter, an eye doctor, makes the equivalent of $600 a month. “She graduated from medical school, and she’s paid like a street cleaner,” Tsulayeva said.

“All we hear is lies,” she said, “so how can I believe the election results? We need to change everything. We need to change from the very top.”

Darkness was falling. The water in the canal along the island called Bolotnaya sparkled under the streetlights. Tsulayeva was tired after a long day of work, but she lingered, listening to the last of the speeches.

“I knew I had to be here,” she said.