For more than 30 years, the Popular Party (PP) and Socialists had alternated power, but they now find themselves challenged by Podemos and centrist party Ciudadanos, which came fourth in the closely-fought legislative polls.
While it took the largest share of the votes, the PP lost its absolute majority in parliament by a significant margin and will now have to try and form an uneasy alliance with other parties or attempt to rule as a minority government.
“We are starting a new political era in our country,” gushed Pablo Iglesias, the pony-tailed, 37-year-old Podemos leader, as supporters looked on holding purple balloons to match the colours of the party.
The country's long-established Socialists, meanwhile, scored their worst score in modern history – challenged as they were by Podemos, which has skillfully managed to surf on the wave of exasperation over austerity and corruption that saw it emerge in the first place.
The polls cap a year of electoral change in southern Europe after Syriza was swept to power in Greece in January and a coalition of leftist parties in Portugal pooled their votes in parliament to unseat the conservative government after an inconclusive election in October.
Official results showed the ruling PP obtained 122 seats – 64 less than in 2011 – with 28.7 percent of the votes.
The PSOE followed with 91 seats and 22 percent of the vote, then Podemos with 69 seats and 20.6 percent, and finally centrists Ciudadanos got 40 seats or nearly 14 percent.
The results mean that the parliament will be constituted of four main groupings of significant clout, as opposed to the usual PP and Socialists.
“For the first time, we will not know who will be Spanish prime minister this evening,” political analyst Josep Antich said on television, pointing to the negotiations that will now ensue to form alliances to try and unseat the PP or keep it in power.
And even if the PP emerges unscathed, it will rule as a minority government.
“The PP's victory is a Pyrrhic victory,” analyst Joaquin Estefania told Spanish radio.
“With a parliament like this, it will have a lot of problems to govern.”
And in front of the PP's headquarters in Madrid, the atmosphere was far from festive.
“This is a disaster, a disaster,” said Carmen Terron Lopez, a 71-year-old retiree.
“Without (Prime Minister Mariano) Rajoy Spain will plunge in total chaos.”
The new colours of Spain. Map: Ministry of interior
End of 'ancient parties'
Sky-high unemployment, inequality, corruption and an ever-rising separatist drive in Catalonia were just some of the issues at stake in a country deeply scarred by a financial crisis and fed up with what many considered a staid political scene.
Rajoy, the austere 60-year-old incumbent premier and PP leader, had positioned himself as a safe pair of hands who dragged the country away from economic collapse when he took power in 2011 and put it on the path of recovery.
But unemployment remains stubbornly high at more than 21 percent.
During the campaign Rajoy's rivals also pointed to glaring inequalities brought on by his drastic spending cuts, tax rises and health reforms – and none more so than Iglesias.
“On the 21st there must be smiles on the faces of all those modest people who can give a lesson to the powerful,” he tweeted just days before the elections.
Seen as running out of steam just months ago, Podemos gained ground again thanks to Iglesias's down-to-earth appeal and his move away from the more radical, far-left ideals and rhetoric his party once espoused.
Meanwhile centrist Ciudadanos led by 36-year-old Albert Rivera, which until just weeks ago was seen as playing the role of kingmaker, only came fourth but will still wield influence in parliament.
“The two ancient parties, the old left and the old right, won't have power anymore,” enthused Ciudadanos deputy leader Jose Manuel Villegas.
Among the PSOE camp, the mood was cautiously optimistic.
“I was born in a country where these types of results are quite usual,” Italian photographer Enrico May, who has lived in Spain for 17 years and supports the Socialists, said in Madrid.
“You have to make alliances. And not be like dogs fighting each other. Because that's kind of the adage of Julius Caesar – divide and conquer.”