Spain’s ruling Socialists have claimed victory in the third election in four years, but have fallen short of a majority.
PM Pedro Sánchez’s party polled 29% and will need the help of either left-wing Podemos and regional parties or the centre right to form a government.
For the first time since military rule ended in the 1970s, a far-right party is set to enter parliament.
Vox opposes multiculturalism, feminism and unrestricted migration.
- Socialists battle to stop right-wing surge
- Pedro Sánchez: Spain’s accidental PM on a roll
With almost all the results in, Vox was on more than 10% of the vote, which would give it 24 seats in the 350-seat parliament.
In his victory speech, Mr Sánchez said the party’s big challenges were to fight inequality, advance co-existence and halt corruption. “The future has won and the past has lost,” he told cheering supporters.
The other big story of the election was the collapse in support for the Popular Party (PP), which governed Spain until it was dumped from power in May 2018 in a no-confidence vote.
That leaves the two parties 11 seats short of the necessary 176 for a majority.
Mr Sánchez could make up the numbers with smaller regional parties, including Basque nationalists, but he is likely to need the help of Catalan pro-independence parties, which withdrew their support for his government last month, forcing the election.
The centre-left Catalan ERC was the big winner in Catalonia, with a projected 15 seats. Its leader, Oriol Junqueras, is in jail for his role in declaring independence in October 2017.
The historic defeat means that, even with the support of centre-right Ciudadanos (Citizens) and Vox, the PP has no chance of forming a coalition.
Turnout was 75.8%, the biggest for several years and 9% higher than the previous election in 2016.
Who are Vox?
Led by Santiago Abascal, a former member of the conservative PP, the party has emerged in a matter of months with a vow to “make Spain great again”.
It won seats for the first time in local elections in the southern Andalusia region, and agreed to support a centre-right coalition of the PP and Ciudadanos.
Vox rejects the far-right label but its views on immigration and Islam place it in line with far-right and populist parties elsewhere in Europe.
It wants to repeal laws against gender violence, and opposes abortion and same-sex marriage. Critics see it as a nationalist throwback to fascist dictator Francisco Franco, who ruled Spain until his death in 1975.
Vox aims to deport migrants legally entitled to be in Spain if they have committed an offence, and wants to prevent any migrant who comes in illegally from staying.
Can Sánchez form a government?
He can choose either to look to the left or to the centre right.
If he looks left, the leader of his earlier coalition partner Podemos, Pablo Iglesias, made clear on Sunday night that another administration was possible.
But the results appear to make any left-coalition dependent on Catalan pro-independence parties, which opponents on the right see as toxic.
The Socialists could govern instead with the centre-right Ciudadanos, but leader Albert Rivera was bitterly critical of Mr Sánchez’s collaboration with Catalan separatists, referring to his earlier “Frankenstein government”.
As the Socialist leader gave his victory speech late on Sunday, supporters chanted “Not with Rivera!”, making it clear they did not want a coalition with Ciudadanos.
Why is Catalonia so important?
The future of Spain’s north-eastern region was one of the big issues of the election.
The semi-autonomous region held an independence referendum in October 2017 and then declared its independence from Spain.
A dozen of its leaders have since gone on trial in Madrid, facing charges including rebellion and sedition. Mr Junqueras was Catalan vice-president when he was arrested.
Analysts say support for Vox has been boosted by widespread anger at the independence drive. The party fervently opposes any concessions to the secessionists.