Spain's Socialist leader Pedro Sanchez has claimed victory in a snap general election after his party won the most seats in parliament but fell short of an absolute majority.
"The Socialists have won the general election and with it the future has won and the past has lost," he told cheering supporters from the balcony of the party's headquarters in Madrid.
The right-wing mainstream conservative PP party was pegged at just 65 seats, with centre-right Ciudadanos on 57 and far-right Vox on 24.
After a tense campaign dominated by issues such as national identity and gender equality, the likelihood that any coalition deal will take weeks or months to be brokered will feed into a broader mood of political uncertainty across Europe.

People cast their votes during Spain's general election in a polling station in Barcelona. Source: AAP
At least five parties from across the political spectrum have a chance of being in government and they could struggle to agree on a deal between them, meaning a repeat election is one of several possible outcomes.
A few things are clear, however, based on opinion polls and conversations with party insiders. No single party will get a majority; the Socialist party of outgoing Prime Minister Pedro Sanchez is leading the race, and there will be lawmakers from the far-right Vox party.
Beyond that, the result is too close to call.

A woman picks a ballot paper during general elections at a polling station in Barcelona. Source: AAP
Voting started at 9am on Sunday and ends at 8pm in mainland Spain for what will be the country's third national election in four years, each of which has brought a further dislocation of the political landscape.
It is uncertain if Sanchez will manage to stay in office and how many allies he would need to gather together in order to do so.
If, in addition to far-left anti-austerity party Podemos and other small parties, Sanchez also needs the support of Catalan separatist lawmakers, talks will be long and their outcome unclear.

Nuns cast her vote during general elections at a polling station in Cordoba, Spain. Source: AAP
Opinion polls have suggested it will be harder for a right-wing split between three parties - the centre-right Ciudadanos, conservative People's Party and Vox - to clinch a majority, but this scenario is within polls' margin of error and cannot be ruled out.
With the trauma of military dictatorship under Francisco Franco, who died in 1975, still fresh in the memory for its older generation, Spain had long been seen as resistant to the wave of nationalist, populist parties spreading across much of Europe.
But this time Vox will get seats, boosted by voter discontent with traditional parties, its focus on widespread anger at Catalonia's independence drive, and non-mainstream views that include opposing a law on gender violence it says discriminates against men.

President of right-wing party Vox, Santiago Abascal, addresses the media after casting his vote. Source: AAP
One of several unknowns is how big an entry Vox will make in parliament's lower house, with opinion polls having given a wide range of forecasts and struggled to pin down the party's voter base.
The high number of undecided voters - in some surveys as many as four in ten - has also complicated the task of predicting the outcome, as have the intricacies of a complex electoral system under which 52 constituencies elect 350 lawmakers.
Voters in the depopulating rural heartlands - many of whom are old and may well feel little direct connection to the country's young, male, urban political elite - are of particular importance.
They proportionally elect more lawmakers than the inhabitants of big cities, but at the same time the cut-off point for parliamentary representation there is trickier to reach, making the outcome harder to predict the more parties there are.

