Simmering popular anger led to setbacks for Russia's ruling party in closely watched races in Moscow on Sunday, even as the Kremlin used its tight control of the electoral system to ensure wins for its hand-picked candidates in gubernatorial votes elsewhere.

After weeks of the biggest anti-Kremlin demonstrations in seven years in the capital, the United Russia party lost a third of its seats in the Moscow City Council election even though nearly all major opposition candidates were kept off the ballot.

In the main contests, strong rivals to the Kremlin's choices for the 16 governor posts were largely blocked from running, ensuring wins for the candidates backed by President Vladimir Putin. Some analysts had forecast that the least popular might not get the 50% needed to win in the first round, but preliminary results suggested all had cleared that bar.

Nationally, the Kremlin avoided repeating the embarrassment it suffered last year, when three United Russia incumbents lost gubernatorial races amid widespread anger over an increase to the pension age. But the opposition is claiming a victory, with the results showing that popular opposition is visible even in Russia's stage-managed elections.

"The Kremlin has learned last year's lesson: When the social mood and economic situation isn't great, the only way to win is shepherd in the candidates to avoid letting an anti-authority mood awaken in the voters," said Boris Makarenko, an analyst at the Center for Political Technologies.

In the capital, rivals to the ruling party won 20 seats in the 45-person chamber, compared to seven in 2014. Among the defeated politicians were longtime council chairman and the head of United Russia's Moscow unit, Andrey Metelsky, and the deputy rector of the Higher School of Economics, Valeria Kasamara.

Kremlin critics said the results showed the success of their strategy of calling on supporters to vote for individual candidates, seeking to concentrate their support. The opposition was testing the strategy, dubbed "smart voting," ahead of the 2021 nationwide elections to the lower house of parliament.

The results were a defeat for the mayor's office, said Alexey Chesnakov, a former senior Kremlin official. "There was a pointed refusal of United Russia," Chesnakov said. "Both the opposition and, more importantly, the voters felt that the authorities are afraid and that the government wants to deceive them. It's not just an embarrassment, it's a mistake."

Moscow Mayor Sergei Sobyanin was magnanimous in defeat, tweeting "the council has become more politically diverse which, I hope, will benefit the city parliament."

The triumph of the opposition is likely to be largely symbolic, given the City Council's limited powers. The biggest beneficiary from the protest vote was the Communist Party, which often votes with the ruling party on important issues.