Donald Trump has been accused of 'malfunctioning in real time' as he enthusiastically praised the "great news" of Spain's socialist government losing the election.

The left-wing Prime Minister Pedro Sánchez stepped down as leader of the Socialist Party on Monday, following his defeat in the national election. He announced he would not retain his seat in Parliament and indicated he was stepping away from frontline politics.

Upon being informed by a reporter that Sánchez's Socialist Party was heading for defeat, Trump responded on Sunday: "That's a good thing!" adding, "He did a terrible job; he deserves to lose."

• CNN's Harry Enten humiliates Trump as he claims 'no one is picking up on AI name change'

• Jesse Watters shouts ‘why am I defending a Democrat?’ as he discusses stock scandal

Trump then appeared to do a double take, saying: "Wait a minute. Sanchez lost, huh? That's great news." Critics were quick to leap on this, with one X user writing: "Malfunctioning in real time." Another user wrote: "Uhhhh…bro just had a mini stroke, it seems…"

A third uncharitable suggestion about Trump: "He literally glitches in real time."

The president later took to Truth Social, writing: "Spain has a chance to be great again. Liberal "leadership" under Sánchez, a DISASTER, has been soundly defeated. Congratulations to Alberto Núñez Feijoo, a strong Conservative, on this very big and important win!"

Spain's conservative and far-right parties secured enough seats on Sunday to form a new government, effectively ending Sánchez's eight-year reign.

Donald Trump speaks to the media after returning the White House from Thanksgiving weekend

"Yesterday, unfortunately, the parties of the left weren't able to win a majority, while another coalition was. That can't be ignored," Sánchez stated in a brief address delivered at party headquarters.

Sánchez had led the country for over eight years, during which time he stood firm against Trump over the use of Spanish military bases to support US airstrikes on Iran. His loss and subsequent resignation mark the end of nearly a decade in which Spain stood at the forefront of progressive initiatives, including advocacy for women's rights, renewable energy, vocal condemnation of Israel's actions toward Palestinians, and a welcoming immigration policy during a period when much of Europe was tightening its borders.

In 2025, when Sánchez openly declined to endorse a defense spending hike agreed upon by other NATO nations, he drew Trump's criticism - becoming a figurehead of defiance for the European left.

The new administration will feature a far-right, nationalist party for the first time since dictator Francisco Franco's death in 1975.