Spain’s Socialist prime minister, Pedro Sanchez, conceded defeat in Sunday’s general election after eight years leading minority governments. The conservative Popular Party (PP) finished first, and parties on the right together won a majority of seats. The Socialists came second and lacked the parliamentary support Sanchez needed for another term.

Sanchez, 54, called his autobiography Resistance Manual. Just last week he reminded a television interviewer how often predictions of his political exit had proved wrong. He survived a revolt within his own party before taking office in 2018, when parliament ousted conservative Prime Minister Mariano Rajoy in a no-confidence vote.

The Socialists had also come second in 2023, but Sanchez won another term with support from smaller parties. His concessions included an amnesty for Catalan separatists who took part in the failed push for independence in 2017. Sanchez had opposed the amnesty, and critics on the right accused him of betrayal when he changed course.

In that final term, Sanchez could not get a new budget through parliament. His government faced floods that devastated Valencia in 2024 and two high-speed rail crashes that together killed more than 100 people in 2026. Corruption investigations involving Sanchez’s allies also hurt his government. In June, Jose Luis Abalos, his former transport minister and a close confidant, received a 24-year prison sentence.

Spain’s economy grew faster than those of many of its neighbours, but inflation and rising housing costs limited the gains households saw in their living standards. PP leader Alberto Nunez Feijoo singled out the cost of housing in Thursday’s final televised election debate.

Few European leaders made the economic case for immigration as openly as Sanchez did. He introduced a special programme that gave undocumented migrants a way to obtain legal status. In July, more than 70,000 people entered Ceuta, a Spanish territory, from Morocco. Opposition parties, particularly far-right Vox, sharply criticised the government over the crossings.

Despite the divisions at home, Sanchez became one of the European left’s few remaining leaders of international stature. His government expanded transgender rights and legalised euthanasia. It also raised the minimum wage and restricted employers’ use of temporary contracts. Ana Sofia Cardenal, a political scientist at the Open University of Catalonia, told AFP that Sanchez had directed his policies towards people who struggled most to get by.

Foreign policy gave Sanchez some respite from the political opposition he faced at home, Toni Rodon, a political scientist at Barcelona’s Pompeu Fabra University, told AFP. Sanchez accused Israel of genocide in Gaza, an allegation Israel rejects. He opposed the war in Iran and rebuffed US President Donald Trump’s demand that Spain spend more on defence. On Sunday Trump called Sanchez’s defeat “great news”.

Socialist supporters had hoped for one more comeback. The PP could now form a government with Vox. If the two parties govern together, the far right will enter Spain’s national government for the first time since democracy returned in the 1970s. Socialist Party activist Toni Alba said he feared that progressive policies would be reversed.