MOSCOW – 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, hand-picked 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.”

Leonid Volkov, Navalny’s campaign manager, said the campaign would press for a runoff. “About 100,000 people voted at home and somehow their votes went to Sobyanin.”