The results offer Pedro Sanchez, its leader, a chance to form a government with left-wing Unidas Podemos (UP) and regional nationalist parties.
Since becoming prime minister in 2018, Sanchez, 47, has taken PSOE from near-irrelevance back to its position as the most popular party in Spain.
He became the country’s prime minister after a no-confidence vote against Mariano Rajoy, from the centre-right People’s Party (PP), who ruled since 2011.
Sanchez was widely considered the winner of televised debates leading up to the elections, which appears to have won over undecided voters.
Who is Sanchez?
Sanchez, who hails from Madrid, is a lawyer who has worked with the centre-left party since 1993.
He has served as PSOE’s general secretary since 2014, when the party was in the midst of a downward slope after five years of PP victories.
Sanchez was little known when he became the socialist leader. He left his post in 2016 to resume it in 2017.
When Sanchez became prime minister, PSOE held 84 seats and had a tense coalition with UP and other regional parties.
Sanchez relied on support from Catalan nationalist parties, who rejected his party’s budget proposal in February, leading to early elections being called.
Where does he stand on the issues?
Sanchez is centre-left in many of his positions, including international issues like immigration and refugees, the European Union and the economy.
PSOE backed a move to exhume Francisco Franco in 2018, though it faced opposition from his family and Vox, which views Franco’s rule favourably.
The remains of Spain’s fascist dictator, who ruled from 1939 until 1975, lie at the Valley of the Fallen, a monumental compound which includes a large basilica, constructed in part by his political enemies.
Sanchez is also socially liberal and supports LGBT rights and women’s right to abortion.
Sanchez and Podemos leader Pablo Iglesias agreed to the biggest wage hike in 40 years in 2018 as part of a series of agreements on the 2019 budget, raising the minimum wage by 22 percent.
That budget did not pass.
Regarding Catalonia’s independence, Sanchez has said he would reinitiate dialogue with Catalan leaders, whose independence drive in 2017 shook Spain and the EU.
This came in contrast to the right-wing bloc, headed by PP, which supported stripping Catalonia of its regional autonomy and placing it under the direct rule of the national government.
However, Sanchez has explicitly stated there would be no independence, or even a state-recognised referendum on secession.