Pedro Sanchez looked a relieved man as the results of the 20 December Spanish election came in, despite his Socialist party (PSOE) having recorded its worst result in the four decades since democracy was restored in Spain.
With 22% of the vote, PSOE came second, edging the anti-austerity upstarts of Podemos by one percentage point. That difference meant more than 20 extra seats for the established party of the left in Spain and a lifeline for Mr Sanchez, under internal pressure for the leadership of the party.
Now, six weeks after the elections, King Felipe VI has asked Mr Sanchez to form a government, after acting Prime Minister Mariano Rajoy finally admitted he could not command a parliamentary majority.
Mr Rajoy's conservative Popular Party (PP) won the election but fell well short of a majority.
"Spain wants the left; Spain wants change," Mr Sanchez proclaimed as the result emerged.
And yet, now that he has been given the chance of power, the parliamentary arithmetic could hardly be more of a strain on his own political survival.
His party could govern with the support of Podemos and a deal with Basque nationalist groups.
But Pablo Iglesias's two-year-old radical left party is making any deal extremely uncomfortable to negotiate.
Indeed, the aggressive tone he has taken towards Mr Sanchez suggests he is more interested in fresh elections being called, a scenario the Podemos leader has said would favour his fast-rising party.
Podemos has consistently stated its insistence on holding a referendum on independence in Catalonia, anathema to the Socialists.
Pablo Iglesias's approach appears to be to keep the Socialist leader at a disadvantage. He went public on his plan to join the Socialists in an evenly shared coalition government before the two had even discussed it.
To make matters worse, senior figures in Mr Sanchez's party seem to have the knives out for their leader.
Felipe Gonzalez, Spain's longest-serving prime minister, said PSOE was wrong to stop the Popular Party from governing.
And criticism by Andalucia's Socialist leader, Susana Diaz, of any approach towards Podemos has been leaked to the media.
She is touted by many as the next Socialist leader. Mr Sanchez will have to stand in party primaries in May if he wishes to stay in his job.
Mr Sanchez has said he will submit any eventual coalition deal to party members for their approval, in an attempt to break free of the shackles that many of the Socialists' party's national executive seem to wish to place on him.
Tired of Podemos's attempts to bounce him into a coalition with Pablo Iglesias as deputy PM and the inclusion of the smaller United Left party, he has indicated he wants to negotiate with the centrist Ciudadanos (Citizens) party.
Like the Socialists, the pro-business Ciudadanos, led by fresh-faced Albert Rivera, are set against Catalan independence.
But the two parties together have 130 seats, well short of the 176 needed for a majority in Congress. And Pablo Iglesias has indicated he will not take part in any coalition deal with Ciudadanos.
Sources close to Mr Sanchez told the BBC that talks with the different groups were "at a very early stage".
He said on Tuesday night he would need at least a month to bring "all of the parties of change" together, citing four main areas in which he would seek cross-party deals: unemployment, inequality, the fight against corruption and creating a federal Spain to solve the Catalan question.
The Socialist leader is determined to march forwards, even if he ends up falling into a trap set by Podemos or his own internal party rivals.
Or maybe, like Don Quixote, he is merely tilting at windmills. "I am fully aware of the challenge I am facing," he said on being nominated by the king, ending his speech by quoting Cervantes: "Good spirits repair any wrong."