LONDON—In political communications, they call it a “grip and grin” or a “spray”: Two leaders shake hands and answer a couple of shouted questions while photographers capture the occasion for posterity. Two or three minutes are typically allocated in the diplomatic schedules that have been painstakingly constructed over months of meetings. On Tuesday morning, Donald Trump tossed the entire plan into the trash and embarked on a 52-minute free-association ramble through global affairs.

It’s exactly why everyone was dreading this NATO leaders meeting.

The hosts for this 70th anniversary bash—the British government and the royal family—are both tip-toeing their way through extremely delicate domestic matters. Boris Johnson is trying to convince the nation to vote him back into No. 10 in an election he didn’t need to call, while the Queen and senior royals are trying to contain the damage caused by lurid allegations of sex-trafficking leveled at Prince Andrew.

NATO itself is still smarting from the U.S. president’s previous threats to blow up the alliance over defense-spending contributions from across Europe as well as French President Emmanuel Macron’s warning that the alliance was experiencing “brain death.”

To try and make sure there were no more shockwaves, the whole event was pared back to a one-day session with a single afternoon of press conferences Wednesday. The last thing anyone needed was a renegade president shooting his mouth off. And yet here we are.

Jens Stoltenberg, the NATO secretary-general, was the leader who happened to be sitting alongside Trump when he set off on his first unscheduled Q&A in London. The Norwegian’s normally inscrutable façade was tested to breaking point as Trump tried to get him to nod along with increasingly wild assertions about how much money he was going to wring out of his “delinquent” NATO partners.

Trump had been beseeched by the British hosts to stay out of their election as the unpopular U.S. president’s support for the Conservatives is seen as electorally damaging. Behind the scenes, London has been pleading with the White House for cooperation; Johnson even asked him publicly to keep out of it last week: “We don’t traditionally get involved in each other’s election campaigns,” he warned.

When asked about the vote by a reporter, Trump tried to stick to the plan. “I'll stay out of it,” he said. Before accidentally endorsing the man he has called “Britain’s Trump” in the very same sentence.

“I’ll stay out of it, but Boris is very capable and I think he will do a good job,” he said.

Of course, whatever the advisers in London or Washington tell him, Trump believes he’s electoral dynamite. “I’ve won a lot of elections for a lot of people,” he boasted.

The Labour party, which has closed the gap on the Tories but still lags behind, is hoping Trump might still win the Dec. 12 election for them. Jeremy Corbyn has tried to make Johnson’s relationship with Trump a key factor in the campaign, claiming that Britain would sell out the National Health Service to Trump and the U.S. pharmaceutical companies as the price for a post-Brexit free trade deal.

“If you handed it to us on a silver platter, we’d want nothing to do with [the NHS],” said Trump, following the script.

“I don’t even know where that rumor started,” he continued, not following the script, and thus reminding everyone that it was he who said the NHS would be on the table during trade talks when he visited London in June.

Trump’s visits to Britain appear to have been among his favorite foreign outings—despite crowds of protesters booing his every move—because of his evident joy at being surrounded by the pomp and circumstance of the royal family.

He was invited back to Buckingham Palace on Tuesday for a world leaders’ reception hosted by the Queen. The British authorities went out of their way to make him feel welcome, installing unprecedented road blocks to prevent thousands of protesters from coming within half a mile of the palace to greet Trump’s arrival. One of the demonstrators told The Daily Beast she hadn’t seen such a powerful police presence in London since an infamous Vietnam War protest at the U.S. embassy in 1968 ended with 86 people injured.

The Queen is currently battling one of the worst scandals of her reign after her son was accused of sexual abuse by Virginia Roberts Giuffre, who was just 17 when she was flown to London by Jeffrey Epstein. Giuffre alleges that she was made to have sex with the Duke of York on three separate occasions.

Prince Andrew deepened the crisis by giving an appalling interview to the BBC in which he said he still did not regret his friendship with Epstein, and claimed he had no recollection of meeting Giuffre despite a photograph that appears to show him with his arm around her waist.

Trump also tried—and failed—not to trample onto that territory. “It’s a tough story, it’s a very tough story,” he said.

He also made the surprising claim: “I don’t know Prince Andrew.” At least half a dozen photographs of the men in conversation at different events over the years would suggest otherwise.

As the Trump fire hydrant continued to blast the world’s media, Stoltenberg periodically interjected by trying in vain to bring proceedings back to NATO priorities.

Macron put up a much better fight when Trump got going at a second out-of-control “pool spray” a few hours later. Trump had earlier described his French counterpart’s NATO remarks as “nasty” and “very insulting.”

The president of France refused to be steamrolled—saying he stood by his “brain death” quote. The two men made little effort to conceal their differences. Macron contradicted Trump, telling the U.S. president that his claim to have ended the ISIS problem was false. “It is not yet done, I’m sorry to say that,” Macron said, pointing at Trump as the U.S. president looked down at the ground.

Trump asked if he was ready to take back the French ISIS fighters, and Macron rejected the idea that Europe was responsible for the ongoing issues in Syria. Trump smirked at the cameras and concluded, “That was one of the greatest non-answers I’ve ever heard.”