Sanchez, in office since 2018, won the backing of 179 lawmakers, three more than the absolute majority of 176 in the 350-seat parliament after an often tense two-day debate.
His Socialist party finished second in an inconclusive July general election but he reached deals with several smaller parties to back re-establishing his minority coalition government with hard-left party Sumar.
To win the support of two Catalan separatist parties, he agreed to grant an amnesty to hundreds of people facing legal action for their role in Catalonia‘s separatist movement over the past decade.
Among the beneficiaries is Carles Puigdemont, who headed the regional government of Catalonia when it staged a failed secession bid in 2017.
Puigdemont organised a referendum that was banned by the central government, followed by a short-lived declaration of independence that sparked Spain’s worst political crisis in decades.
He fled to Belgium to avoid prosecution. An amnesty would allow him to return to Spain, while many Spaniards consider him an enemy of the state.
Sanchez, who has made a career out of making political gambles, defended the amnesty during the parliamentary debate, arguing it was constitutional and needed to “heal the wounds” opened by the wealthy northeastern region’s independence push.
“We will guarantee the unity of Spain through dialogue and forgiveness,” the 51-year-old added.
– ‘Coup d’etat’ –
Critics say the amnesty is a self-serving measure to allow Sanchez to remain in power and accuse him of trampling on the rule of law.
The amnesty “hurts our international reputation and undoubtedly affects our democracy”, the leader of the conservative Popular Party (PP), Alberto Nunez Feijoo, told reporters after the confidence vote.
The PP won most seats in the July election but fell short of a majority and Feijoo was unable to get support from other parties to win his investiture vote in September.
The leader of the far-right Vox party, Santiago Abascal, has called the amnesty deal a “coup d’etat”.
Several polls show more than half of all Spaniards oppose the amnesty, which has prompted a wave of nationwide protests.
Hundreds of thousands of people took part Sunday in different protests, answering a PP call to take to the streets.
Thousands have congregated each night for more than a week outside the Socialist party’s headquarters in Madrid in rallies organised by the far right. Some protests have turned violent.
Fifteen people were arrested at the protest on Wednesday night following scuffles with police.
Police set up metal barriers to keep several hundred protesters who gathered near parliament during Thursday’s vote from getting near the building. The crowd jeered Socialist lawmakers as they left afterwards.
– No ‘blank cheque’ –
In a sign of the tensions, more than 1,600 police were deployed on Wednesday and Thursday for the parliamentary debate, according to the interior ministry.
Sanchez — one of Europe’s longest-serving Socialist leaders — outlined a series of social measures planned for his new term during the debate.
These include making public transport free for young people and the unemployed, continuing to link pension hikes to inflation, and extending a cut on value added taxes on food to help consumers deal with inflation.
Sanchez also promised to reduce the length of the working week to 37.5 hours from 40 hours and further increase the minimum wage.
He also vowed to maintain Spain’s staunch support for Ukraine and promised to work to “recognise the Palestinian state”.
But Sanchez will likely struggle to pass legislation since the various leftist and regional parties slated to back him on Thursday have radically different ideologies.
A spokeswoman for leftist Basque independence party Bildu, Mertxe Aizpurua, warned Thursday that her party’s yes vote for Sanchez would not be a “blank cheque”.