His detractors labelled him "stubborn" after he repeatedly refused to allow the Popular Party (PP) to be sworn in for a second term following two inconclusive general elections held in 2015 and 2016.
High-ranking party members rebelled in October, replacing Sanchez with a caretaker administration which promptly let the PP form a new government.
The architects of the rebellion said it was best to let a conservative government led by Mariano Rajoy through rather than go to a third election in poll-weary Spain and risk losing even more votes.
But Sanchez called the decision a mistake, arguing that Socialist parties in other European nations who backed conservative governments had slumped in the polls.
After his ouster the 45-year-old former economics professor rebranded himself as an "outsider" who wants to push the party further left to try and reclaim voters who moved to new far-left party Podemos.
He called for an "autonomous, left-wing and credible" Socialist party and argued he was the candidate that best reflected the wishes of grassroots Socialist activists.
Sanchez ended his campaign rallies singing "Internationale", the hymn to world socialism, with his fist raised in the air.
The strategy paid off.
He was elected with just over 50 percent votes cast in the primary held Sunday, compared to around 40 percent for his nearest rival Susana Diaz, president of the southern region of Andalusia, a Socialist stronghold.
Always immaculately suited and booted, tall and with Hollywood looks, Sanchez has made many enemies inside and outside of the party over the past year.
He acknowledges that he has a "very difficult" relationship with Diaz, one of the leaders of the rebellion against him.
Diaz was backed by the bulk of the party's heavyweights, including two former Socialist prime ministers, Felipe Gonzalez and Jose Luis Rodriguez Zapatero, who have been critical of Sanchez.
He is disdainful of Rajoy, deeply critical of corruption scandals impacting the prime minister's ruling PP and of their severe austerity measures.
During a televised debate before a December 2015 general election, he said Rajoy was not "a decent person".
Sources close to Sanchez says he is also wary of Podemos, a party that has made no secret of wanting to replace the Socialists as Spain's main left-wing force, and with whose leader Pablo Iglesias "he has never got along."
Passion for politics
Sanchez was largely unknown when he first took the reins of the Socialist party in July 2014 after winning the first ever primary elections organised by the 138-year-old grouping.
Born in 1972 in Madrid, Sanchez grew up in a wealthy family -- his father an entrepreneur and his mother a civil servant.
He studied in the Spanish capital before getting a Master's degree in political economy at the Universite libre de Bruxelles in Belgium.
Politics, though, was always his passion.
He was an opposition town councillor in Madrid from 2004 to 2009, after which he entered parliament as a lawmaker under Zapatero's administration.
That ended when the PP swept to power in 2011 with an absolute majority, kicking the struggling Socialists out of power.
But he returned to the lower house in 2013 after the resignation of a lawmaker, and then went on to be voted in as Socialist party chief.
In public, he likes to cultivate the image of a good family man with his two daughters and his wife Begona, a dazzling smile always at the ready.
By Alvaro Villalobos / AFP