MADRID (Reuters) - For Spanish Socialist Pedro Sanchez it has been a strange turn of events over the past two years, from losing the leadership of his party to becoming prime minister.

Spain's new Prime Minister and Socialist party (PSOE) leader Pedro Sanchez leaves the chamber after a motion of no confidence vote at parliament in Madrid, Spain, June 1, 2018. REUTERS/Sergio Perez

The 46-year-old put his political career on the line in 2016, when he voted against Mariano Rajoy becoming premier in a parliamentary ballot, sowing divisions within his party after most other members abstained to avert the need for a snap election.

Now he has succeeded Rajoy as Spain’s seventh prime minister since its return to democracy in the late 1970s, and has pledged to remain at the helm to mid-2020 when the current parliamentary term ends.

To achieve that ambition he will have to draw on all the skills he has acquired during his 25 years in politics.

The Socialists hold just 84 seats in the 350-seat chamber, so the mere process of staying in office is likely to be arduous.

Sanchez will also be under pressure to resolve a secession crisis in the Catalonia region, keep a strong economic recovery on track and shield his 139-year-old party from the rise of liberal and leftist opponents Ciudadanos and Podemos.

“I am aware of the responsibility I am assuming, of the complex political moment our country is going through and I will rise to all the challenges with humility and dedication,” Sanchez told reporters.

“I am willing to modernize and transform the country and to attend to the urgent social issues of the many people who suffer ...inequality.”

Passionately pro-European, Sanchez studied for a masters in economic policy in Brussels and he has worked in the European Parliament and the United Nations.

Slideshow ( 2 images )

He has committed to respecting the European Union’s fiscal rules and has already endorsed Rajoy’s budget. His weak hand in parliament means he is also unlikely to rescind any of the structural reforms the conservatives passed.

“NO MEANS NO”

Often underestimated by his opponents, including Rajoy and former socialist rival Susana Diaz, Sanchez gained a reputation for both perseverance and stubbornness when in 2016 he stuck to his “no means no” mantra against enabling a Rajoy government.

His supporters say he has a calm personality and a talent for compromise. Opponents say he lacks charisma and a clear political vision.

Under his leadership, the Spanish Socialist and Workers’ Party (PSOE), which Sanchez joined at 21, has suffered the fate of many of its left-wing peers across Europe where traditional political identities have been undermined by populist leaders from across the political spectrum.

The PSOE has struggled to carve out a role in the new fragmented political landscape that emerged from the worst economic crisis since the Spanish civil war of the 1930s and ended four decades of a stable two-party system.

Sanchez lost two national elections to Rajoy’s People’s Party in 2015 and 2016.

He has struggled in opinion polls since he took the leadership of the party in 2014 and recovered it in 2016 after he was briefly ousted for opposing his party’s abstention vote over Rajoy.

The wounds inside the party have remained profound and Sanchez has relied on the strong support he enjoys from the party’s grassroots rather than its elite, something which could make it harder for him to form a strong government.

A basketball fan, he is married to a marketing professional and is father to two daughters.