A strong showing Sunday by a pair of upstart parties in Spain's general election has upended the country's traditional two-party system, with the ruling Popular Party winning the most votes but falling far short of a parliamentary majority and at risk of being booted from power.

Days or weeks of negotiations may be needed to determine who will govern Spain, with the new far-left Podemos and business-friendly Ciudadanos parties producing shockwaves because of strong support from voters weary of high unemployment, a seemingly endless string of official corruption cases and disgust over the country's political status quo.

If forced out of government, Prime Minister Mariano Rajoy and his Popular Party would become the third European victims this year of a voter backlash against austerity — following elections in Greece and Portugal seen as ballot box rebellions against unpopular tax hikes and spending cuts invoked during the eurozone's debt crisis.

In past Spanish elections, the Popular Party and the main opposition Socialists were the established powerhouses and only needed support from tiny parties to get a majority in parliament when they didn't win one from voters.

Period of uncertainty

But Podemos came in a strong third place and Ciudadanos took fourth in their first election fielding national candidates — setting up a period of uncertainty as parties negotiate with each other to see which ones may be able to form a governing alliance.

"Spain is not going to be the same anymore and we are very happy," said a jubilant Pablo Iglesias, the pony-tailed leader of Podemos.

With 99.9 percent of the vote counted, the Popular Party won 123 seats in the 350-member lower house of Parliament — far below the 186-seat majority it won four years ago after beating the Socialists in a landslide.

The Socialist Party received 90 seats, while Podemos and allies won 69 and Ciudadanos got 40.

Analysts said the outcome will make it extremely difficult for the Popular Party to form a government because it cannot get a majority of seats in parliament by allying with Ciudadanos, its most natural and closest ideological partner. Spain has never had a so called "grand coalition" that would bring the Popular Party and the Socialists together.

'Coalition of losers'

The Socialists could try to team up with Podemos and Ciudadanos in a three-way "coalition of losers" similar to an electoral outcome that happened in neighbouring Portugal last month. Also possible for the Socialists is a deal with Podemos plus smaller regional parties that won just a few seats each — not requiring the support of Ciudadanos.

Prime Minister Mariano Rajoy told cheering supporters shortly after midnight Monday that he would try to form a government but didn't provide any details of how he might accomplish that goal.

"This party is still the No. 1 force in Spain," Rajoy declared.

But Socialist leader Pedro Sanchez said the result clearly shows "Spain wants a move to the left," adding that he and his party are ready for talks that could lead to a governing accord.

"If the current poll predictions are confirmed, then it looks like a Socialist government," said Federico Santi, a London-based analyst with the Eurasia Group political risk consultancy.

Spain Election

Popular Party supporters rally outside the party's headquarters following the national elections in Madrid on Sunday. The governing party won the most votes, but could lose power to a three-party coalition. (Paul White/Associated Press)

"Reaching a deal between the Socialists, Ciudadanos and Podemos is not going to be straightforward ... but if the alternative is leaving the country without a government, the pressure will be on the parties."

Podemos and Ciudadanos both gained strength by portraying the Popular Party and the Socialists as out-of-touch behemoths run by politicians who care more about maintaining their own power than citizens' needs.

Spain's 36.5 million registered voters were electing representatives to the lower house of parliament and to the Senate, which has less legislative power. Voting was brisk with lines outside some polling station and voter participation of 58.4 per cent by 6 p.m., up slightly compared to the 2011 election.

Economic crisis

The nation's devastating economic crisis, non-stop corruption scandals and a separatist drive in the northeastern region of Catalonia have dominated Spanish politics over the past four years. Rajoy has boasted about his handling of the economy, done his best to skirt the corruption minefield and has vowed to halt the independence push.

His administration's biggest success has been in pulling Spain back from an economic abyss in 2012 and returning the economy to steady growth, but the jobless rate has come down slowly and salaries for people entering the workforce are 30-per-cent lower than they were in 2008. This has fuelled claims by Ciudadanos and Podemos that the Socialists plunged Spain into an economic crisis and the Popular Party has failed to fix the problem.


Podemos (We Can) party leader Pablo Iglesias reacts as he arrives to a theatre to follow results in Spain's general election in Madrid. (Andrea Comas/Reuters)

Rajoy's party also adopted unpopular austerity measures and labour and financial reforms that are credited with creating jobs but damaging the country's social welfare system. Although Spain's economy is now one of the fastest-growing in the 28-nation European Union, its unemployment rate is the second-highest in the EU after Greece.

The question of independence for economically and politically powerful Catalonia has divided that region and soured political ties with the rest of Spain. Rajoy vows to quash what is seen as the biggest threat to Spanish unity in recent decades. Other parties favour negotiations to devolve more power to Catalonia.


Ciudadanos party leader Albert Rivera talks to reporters outside a polling station after casting his vote in Spain's general election in Hospitalet de Llobregat, near Barcelona, Spain, Dec. 20, 2015. (Albert Gea/Reuters)

Pedro Sanchez, a 43-year-old former university economics professor, was unknown to most Spaniards until he was elected leader last year of the Socialists.

Political science professor Pablo Iglesias, 37, and his radical left Podemos party want to break the mold of Spanish politics. Podemos was born from massive Madrid street protests in 2011 that drew mainly young Spaniards weary of corruption.

Ciudadanos has the media-savvy Albert Rivera as its leader. At 36, he is the youngest candidate, and his moderate, business-friendly policies plus a pledge to crack down on corruption have attracted voters.