Madrid (AFP) - Spain's "Indignado" protest movement gave its ruling conservative rivals a historic battering in local elections Sunday, topping the vote in Barcelona and shattering the ruling party's majority in Madrid.

In a dramatic shakeup of Spanish politics, an upstart group backed by the anti-austerity protest party Podemos could govern in the capital, a longtime conservative stronghold.

The new political groups, Barcelona En Comu and Ahora Madrid, were formally launched just a few months ago but have already started to loosen the grip of the two big parties that have run Spain for nearly four decades.

The new groups were born out of the "Indignado" ("Outraged") protests that swamped Spanish streets during recent years of economic crisis, campaigning against corruption and unemployment.

Thousands of supporters of both parties rallied in the streets of Madrid and Barcelona, cheering and yelling "Yes we can!"

Ahora Madrid, led by 71-year-old retired judge and grandmother Manuela Carmena, came second behind Spain's governing Popular Party (PP) but could govern the city if it joins forces with the main opposition Socialists, who came third.

"We will remember this as something special and extraordinary," she told supporters in central Madrid.

- 'David and Goliath' -

The Barcelona group's leader Ada Colau is a 41-year-old activist who rose to prominence defending poor homeowners from eviction.

"This will go down in history," she told supporters.

"In this titanic struggle of David versus Goliath, we have won because we did incredible things with scarce resources and the power of the people."

Barcelona En Comu gained just one more seat than its nearest competitors in the city council.

Back in the capital, Carmena has a chance to deal a stunning blow to the PP, which has governed Madrid for 23 years, and to Prime Minister Mariano Rajoy as he braces for a general election due around November.

Colau meanwhile faces a tricky job forging a coalition among a mixture of small rival parties who could unite to block her.

Story continues

To her supporters, her topping the vote felt like a triumph however.

"I am not used to winning, it feels strange," said one of her supporters, 63-year-old Fernando Ramos. He retired last month after a long time unemployed.

"Today is different. The losers have won and it is a great victory."

- Podemos eyes general election -

Podemos, an ally of Greece's left-wing ruling party Syriza, did not run itself in the town elections but placed third in voting for several regional governments.

The PP and Socialists "have had one of the worst results in their history", Podemos's pony-tailed leader Pablo Iglesias told supporters after polls closed on Sunday.

"This spring of change is irreversible and will take us all the way to November. We will take up the challenge of winning the elections against the Popular Party."

Alongside the left-wing protest groups is the economically liberal centrist party Ciudadanos, which came in fourth place in Madrid and Barcelona.

Like Podemos, it has pledged to fight corruption and heal a country stricken by unemployment and spending cuts.

Ciudadanos is luring voters from right and left, promising more moderate, market-friendly reforms seen as less alarming for foreign investors.

Ciudadanos leader Albert Rivera said Sunday's vote made his party "the third biggest municipal party in Spain".

"This is only just beginning," he said. "In Spain there is room for a third way."

The PP won 12 of the 13 regional government votes but lost its absolute majorities.

It won the most votes overall across the cities but saw its support plunge to 27 percent from 37 percent in 2011.

Rajoy has warned that ejecting the PP from office could disrupt Spain's economic recovery.

"We will manage our majority with humility," one of the PP's leaders, Carlos Floriano, told reporters.

"The next legislature will be one of dialogue and accords."