Vox, the first far-right movement to secure a sizeable parliamentary representation since the death of dictator Francisco Franco, secured just 24 seats.
Far left-wing party Podemos immediately offered to open coalition talks with Sanchez, though the two parties together can not command a majority. Podemos leader Pablo Iglesais said he would happily enter a coalition. Forming such a coalition "will take much time and I would ask for your patience", he added.
With almost all the votes counted, the Socialists together with the far-left Podemos were 11 seats short of a majority in the 350-seat parliament.
Vox takes tough positions against immigration and feminism, and opposes the Catalonian push for independence.
Spanish Prime Minister and Socialist Party candidate Pedro Sanchez casts his vote inside a polling station in Pozuelo de Alarcon, near Madrid.
With the local and European elections due in May, a government might not be formed until June or July.
He has two realistic options to do this.
"This political combination needs the parliamentary support from smaller parties".
Rockets vs. Warriors - Game Recap
The NBA's reigning MVP finished with a team-high 35 points, shooting 9 for 28 from the field and 4 for 16 from beyond the arc. The first game is always trying to figure out how they look at our plays, how they react to it.
Yes, it has led to a polarisation between the Spanish "heartlands" and the "autonomous communities", though this election does show PSOE winning majorities in most of Spain outside of the Basque Country and Catalonia, so it's a complex picture.
It is too early to assert with certainty, but Pedro Sanchez could be free to form a government without relying on the backing of the Catalan separatists who demand an independence vote as the price for their support. The issue was at the heart of the election campaign and has at times unnerved euro zone investors and the rest of the EU. Together, the Socialists and Ciudadanos would have an outright majority.
A possible alliance with Ciudadanos has not been ruled out, even if the party's leader, Albert Rivera, has made "chasing" the socialists from power a "national urgency". Rivera repeated after the election that he would be in the opposition.
Residents in Spain have begun voting in a third general election in four years. EURACTIV's partner efe-epa reports.
That's on the highest turnout ever in a Spanish election, so no one can (or should be able to) deny the democratic legitimacy pro-independence forces have in Catalonia.
On the splintered right, three parties had competed for leadership: the once-dominant conservative Popular Party, the centre-right Citizens, and the nationalist, anti-migrant Vox party.
All 350 seats of the Congress of Deputies, which appoints a government, and 208 seats in the upper house Senate were up for election by the 36.8 million voters.
Santiago Abascal, leader of far right party Vox, is seen at a polling station in Madrid. The rise in support for PSOE was definitely connected to an anti-fascist mood, while the collapse in the PP's support - which fell by 15 per cent, losing the party more than half of their seats - has led to many senior figures say that they did not distance themselves from Vox enough.