Spain's governing conservative party has won the most seats in the general election but 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.
The results showed two-party politics in Spain had ended, Podemos spokesman Inigo Errejon said. "We are entering a new era in our country."
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 percent of the vote, the Socialists 22 percent, Podemos 20.6 percent and Ciudadanos 13.9 percent.
Turnout was put at about 72 percent - up slightly compared to the 2011 election.
Analysts said the PP could find it very difficult to form a government because it couldn'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 percent, the second-highest rate in the EU after Greece, although it has fallen from its 2013 peak of 27 percent.
The PP had also been damaged by corruption scandals.