MOSCOW — Allies of President Vladimir V. Putin of Russia suffered significant losses in Moscow City Council elections, preliminary results showed on Monday, but mostly held their own in other local polls across the country.

Results of the elections, held on Sunday, highlighted the Kremlin’s troubles in the Russian capital, which has been roiled in recent weeks by a wave of protests, while demonstrating its firm grip on politics elsewhere in the vast country.

The governing United Russia party will still form the majority in the city legislature of 45 seats, but the results showed the party’s continuing weakness, as well as the seeming effectiveness of the opposition’s “smart voting” effort, which sought to consolidate voting behind the antigovernment candidate with the best chance of winning.

Beyond Moscow, the Kremlin was still able to demonstrate its full control of the political situation, winning all 16 of the governor’s races. In St. Petersburg, Mr. Putin’s longtime associate, Aleksandr D. Beglov, who was described by Russian news outlets as a “gaffe machine,” won 65 percent of the vote.