LONDON — Spain's long-serving prime minister, Mariano Rajoy, lost a no-confidence motion against his government on Friday, and he prepared for the heartbreak in a way that most of us can probably identify with.

He holed up with a handful of close advisers in a posh restaurant and settled in for a long afternoon.

On Thursday, Spain's parliament held a lengthy debate on the approval of a no confidence motion against Rajoy to be held on Friday, but the prime minister himself was nowhere to be found. With Rajoy and his team reportedly not responding to any form of communication, numerous intrepid journalists searched the area around the Palacio de las Cortes, the home of Spain's parliament.

Although timings cannot be confirmed, it is believed that Rajoy and his team were in the restaurant from around 2 p.m. Madrid time until around 10 p.m. when Rajoy emerged from the restaurant to the waiting press. Footage of this can be seen below:

Rajoy's mammoth lunch came as he stared down the end of his nearly seven years as Spain's most senior politician, with Pedro Sanchez, the leader of the Spanish Socialist Workers' Party (PSOE) set to take over as prime minister.

On Thursday, Sanchez secured the backing of six parties in the lower house of the Spanish parliament, totaling 180 votes. An absolute majority comes from 176 votes, so Sanchez is clear to take power immediately now the vote has passed.

Prior to Thursday's debate, Sanchez had called on Rajoy to resign, preventing him from becoming the first ever Spanish prime minister to lose a vote of no confidence.

"Are you ready to resign? Resign today and leave by your own will," Sanchez told Rajoy, according to a Reuters report.

"You are part of the past, of a chapter the country is about to close."

The no confidence vote against Rajoy comes amid a corruption scandal, known as the Gürtel case. The scandal has seen senior members of Rajoy's People's Party (PP) implicated, with a handful being handed long term jail sentences late in May. Spain's former treasurer, and a close ally of Rajoy, Luis Barcenas, was among those jailed, receiving 33 years in prison. Charges levied against those involved in the scandal included bribery, money laundering and tax evasion.

Rajoy's premiership has been a fractured one, with the right-wing leader holding power through three general elections. The PP won a majority in an election in 2011, but lost that majority in 2015 after a deadlocked election. He remained prime minister, eventually overseeing another election in 2016, when he was able to create a government where he acted as prime minister in a minority government.

Rajoy was also in power during the 2017 Catalan crisis, when the region tried and failed to secede from Spain after holding an unsanctioned election. At the time he faced criticism for the police's heavy handed approach to voters, which saw numerous people injured.