Spanish election: PM Rajoy's party loses majority
Spain's governing conservative party has won the most seats in the general election but has lost its majority and must now try to form a coalition.
With almost all votes counted, the Popular Party (PP) had 123 seats; the Socialists 90 and the anti-austerity Podemos party 69.
The liberal Ciudadanos party was in fourth place with 40 seats.
Podemos and Ciudadanos fielded national candidates for the first time, boosted by discontent among the electorate.
The PP and the Socialists have alternated running the government for more than three decades.
A spokesman for Podemos said the results showed that two-party politics in Spain had ended.
"We are entering a new era in our country," said Inigo Errejon.
Prime Minister Mariano Rajoy's PP needed 176 seats to form a majority. It had 186 seats in the outgoing parliament.
"I will try to form a government, a stable government," Mr Rajoy told PP supporters, after the final results were announced.
"This party is still the number one force in Spain."
The Popular Party had 28.7% of the vote; the Socialists 22%; Podemos 20.6% and Ciudadanos 13.9%.
Turnout was put at about 73% - up slightly compared to the 2011 election.
Analysts said the PP could find it very difficult to form a government because it can't achieve a majority in parliament in coalition with Ciudadanos, its most natural partner.
The Socialists, on the other hand, could form a pact with Podemos and Ciudadanos.
Spain's economy, corruption allegations and a separatist drive in the prosperous north-eastern region of Catalonia were all dominant issues in the election.
Mr Rajoy's administration adopted tough austerity measures and job reforms that, although unpopular, have been credited with returning the Spanish economy to growth.
However, unemployment remains high at 21%, the second-highest rate in the EU after Greece, although it has fallen from its 2013 peak of 27%.
The PP has also been damaged by corruption scandals.
- Spain's electoral system tends to disproportionately favour larger parties.
- MPs are elected in 50 multi-member districts using proportional representation. Each district is home to at least two members.
- Spain's North African enclaves Ceuta and Melilla elect one member each while 248 seats are allocated among the provinces in proportion to their respective populations.
Spain at a crossroads
Housing row in Catalonia: Taking back Barcelona's apartments
Depopulation in rural Castile and Leon: Resisting change in a dying village
Early school-leavers in Murcia: Spain's voters call for shake-up in classroom