Brazil's municipal elections showed that new parties have failed to capitalize on voters' disenchantment with a corruption-tainted political establishment, making it unlikely an outsider will win the 2018 presidential poll.

The political movements nurtured by the anti-corruption street protests of 2013 and 2015, despite a massive presence on social media, won just a handful of mayoral posts and local council seats in Sunday's nationwide polls.

In the first elections since President Dilma Rousseff was dismissed in August for breaking budget rules, her leftist Workers Party lost nearly two-thirds of the cities it controlled, amid a backlash at a massive graft scandal at state oil company Petrobras.

Yet more than 4,000 of Brazil's 5,568 municipalities will remain in the hands of traditional parties aligned with new center-right President Michel Temer, whose Brazilian Democratic Movement Party (PMDB) has also been embroiled in the Petrobras investigation.

Brazil's interim President Michel Temer gestures during the inauguration ceremony of new presidents of state companies, at the Planalto Palace in Brasilia, June 1, 2016.

"We felt like the 300 of Sparta, fighting against the system," said Felipe Camozzato, one of four winning candidates of the New Party, referring to the ancient Greeks' heroic defeat by a far larger Persian force at the battle of Thermopylae.

"We didn't expect to promote change in four years. It's a project for 20, 30, 50 years," said Camozzato, whose party is one of the most popular on Brazilian social media with over 1.2 million Facebook followers.

While new movements have generated an online buzz with pledges to clean up politics, the political machines of Brazil's established parties quietly capitalized on stricter financing rules and a shorter campaign to retain strongholds in smaller towns, a breeding ground for legislative candidates.

The results suggest Brazil's established parties and pork-barrel politics will continue to dominate a fragmented Congress, raising the costs of economic reforms, analysts said.

They also reduced the chances that an outsider could hope to win the presidency in 2018 bypassing the old party machines, despite Brazil's worst economic slowdown in a century.

A woman leaves a polling station during municipal elections in Sao Luis, Brazil, Oct. 2, 2016.

"If a recession like this with over 12 million unemployed failed to create outsiders, how could we expect one in 2018?" said political analyst Luciano Dias, a partner in the consultancy firm CAC.

Planting a Seed

The right-leaning Brazilian Social Democratic Party (PSDB) was the biggest beneficiary of the demise of the Workers Party.

The PSDB wrested control of São Paulo, the country's economic powerhouse, from its leftist rival.

Temer's PMDB lost Rio de Janeiro, Brazil's second biggest city, but held on to the largest number of mayoralties across the country, ensuring it will continue to be the largest Brazilian party. Its allies also advanced in state capital races.

Lucas de Aragão, a political scientist with consultancy Arko Advice, said it was far more important for the PMDB to retain its sweeping geographical footprint than retain control of a single metropolis as that gave it the platform to campaign in legislative polls.

"It will continue to be the most influential party in Congress and, because of its enormous capillarity, the most decisive actor in 2018," he said.

The Socialist PSOL party, seen as the Workers Party's main rival on the left, squeaked into the second round in Rio de Janeiro but elected only two other mayors.

Also on the left, Rede Sustentabilidade, whose leader Marina Silva came third in the 2014 presidential election running for the PSB party, elected just five mayors.

"This election was a victory for conservative forces," said Luiz Araújo, president of the PSOL. "But we planted a seed."

Right-leaning Free Brazil Movement, which staged nationwide protests that helped remove Rousseff from office, elected only eight city council members.

A record number of 31 parties elected at least one mayor, showing Brazil's fragmented party system becoming even more atomized.

A proposal to cut the number of small parties by setting a minimum threshold of votes to remain registered passed a Senate committee last month and could further consolidate the dominance of traditional parties if it becomes law.