First, a little background necessary to provide the framework for understanding the current stand-off. The national politics of post-Franco Spain (since the death of the aged Fascist dictator in 1975) has been dominated by two parties: the Partido Popular (the current version of the center-right, Christian Democrat political forces which took over when El Caudillo finally kicked) and the PSOE (Spanish Socialist Workers Party). They have alternated in power since then, generally sharing 80% or more of the seats in the lower house of Spain's Cortes Generales, in which a majority is needed to determine the Prime Minister. The party which gained the most seats has always been able to form a majority, either alone or in combination with one or more of the many regional parties.
The Socialist government of PM Zapatero fell in 2011, jolted by the terrorist attacks in Madrid and the financial crisis. The PP government of Rajoy imposed austerity reforms required, under the circumstances, to reduce the budget deficit to the levels mandated by the Euro pact. As in Greece, popular reaction against austerity mobilized new forces, the "indignados" (angry) giving way to a new political party, Podemos ("we can"). A fourth major party emerged, Ciudadanos ("citizens"), a centrist party which challenged the PP as a corrupted force which has held back liberalizing reforms.
The last bit of background required to understand the current Spanish political dynamics is the longstanding conflict between the forces of national centralization and the centrifugal tendencies of Spain's regions. Recall the long battle between violent Basque separatists and the national police and military, which finally succeeded in suppressing the extreme forces and channeling Basque ambitions into autonomy. Spain's most wealthy region, Catalonia (Barcelona its capital), opted for the peaceful approach and also gained significant autonomy; however, in recent regional elections a coalition of Catalonian parties seeking a referendum on complete separation has gained power.
As with the Scottish secession movement in Britain, a majority vote in a referendum in favor of separation would create great problems for the state and for the EU: EU policy is that the new state would have to apply for admission (both Scotland's and Catalonia's secessionists have indicated they would want to do it) and the rump state--Britain or Spain--would need to agree in order to allow their admission.
Spain's post-Francoist constitution envisioned a strong central government with the King as head of state; later legislation empowered the recognition of autonomous regions, but secession was ruled by Spain's supreme court to be unconstitutional. Podemos has supported Catalonia's right to hold a referendum, the Socialists have proposed a devolution of power toward a federal state, while the PP and Ciudadanos oppose any referendum.
The Electoral Results and the Current Status+
1- Partido Popular (PP) - led by Mariano Rajoy-- 28.7% of popular vote, 123 seats (down from 187 in 2011)
2- Partido Socialista Obrero Espanol (PSOE) - led by Pedro Sanchez - 22.0%; 90 seats (down from 110)
3-Podemos - led by Pablo Iglesias - 20.7%; 69 seats (new party)
4- Ciudadanos (C's) - led by Albert Rivera - 13.9%; 40 seats (new party)Others - 14.7% of vote; 28 seats.The results definitively signal a rejection of the austerity policy, as well as change from two-party dominance, with the two insurgent parties getting over 40% of the popular vote and enough seats to have an important voice in the nature of the new government to be formed. With 175 seats needed to form a majority government, no single party can approach a majority, even with the support of all the smaller parties (which itself would be next to impossible). It is possible to form a government with less than an absolute majority of support if there are enough abstentions; typically, this would mean the agreement by a party to provide passive support and request all its members to abstain from a vote of confidence.
The PP gets the first shot at forming a government, but they have immediately run into problems: all three of the other top parties have indicated they would not work with Rajoy to form a government, either in coalition or by abstaining in the vote of approval. A PP-Socialist accord would be unprecedented, and the personal rivalry of the leaders would preclude it, as well. Podemos and PP are diametrically opposed on both austerity and the critical issue of the possible Catalonian referendum. In the final stages of the campaign, the PP, which has its strength in rural areas, went after the C's support in the cities to salvage its position as leading party, and the C's, which got a significant result but not as high as they might otherwise have had, now have announced they would oppose any government by the PP.
The next phase would be an attempt by someone else to form a government, possibly a different leading figure of the PP, but more likely an attempt by the PSOE's Sanchez (or possibly another in the party) to form a coalition. If a satisfactory formula can be negotiated on Catalonia, a PSOE-Podemos coalition, or a PSOE-Ciudanos one (with Podemos abstaining, and the support of some smaller parties), or even a three-party coalition against PP, are all possible outcomes. So are a complete deadlock, which would lead to new elections, or the formation of a caretaker government headed by lesser party figures or non-partisan statesmen
After the tribulations with Greece, the refugee issue which exploded in Europe (and threatened the continental agreement to allow free travel within most of the countries), and the British election issues around Scotland, the Spanish election results promise turmoil cointinuing beyond this year of living dangerously.
+ Thanks to Wikipedia for presenting comprehensive data. I would offer a brief ad for that service, which is trying to raise some money to continue its operation.