US President Donald Trump launched a remarkable attack on outgoing UK Prime Minister Theresa May on Tuesday, saying her government had made a “mess” of Brexit.

“I have been very critical about the way the UK and prime minister Theresa May handled Brexit. What a mess she and her representatives have created. I told her how it should be done, but she decided to go another way,” he tweeted.

Trump also tweeted that he refused to deal with the UK ambassador to the US following the leak of his frank assessment of the US president’s chaotic rule.

This attack raises a big question – can the countries’ much-vaunted “special relationship” survive?

The Mail on Sunday’s publication of Ambassador Kim Darroch’s confidential cables set off a furious Trump Twitter storm.

Darroch had called Trump “inept” and his administration “uniquely dysfunctional”.

Trump tweeted back that Darroch “is not liked or well thought of within the U.S. We will no longer deal with him”.

He also welcomed the “good news” that Prime Minister Theresa May was stepping down in two weeks.

All of which creates another headache for UK politicians during a tumultuous period in which they must decide how – or even if – Britain will leave the EU on October 31.

The hunt is on for the leak’s culprit and the “whodunnit” theories are flying.

Most concern the nuanced politics at play in the UK leadership fight between Brexit-backing former London mayor Boris Johnson and underdog Foreign Secretary Jeremy Hunt.

One popular theory says the leak was aimed not at Darroch but at the person who is due to replace him in January.

The senior official tipped for the plum US assignment holds pro-European views that upset most Brexiteers.

This would suggest that the culprit was trying to make sure Johnson – seemingly assured of May’s office – settles on someone else.

But the leak has also damaged foreign standing and some talk is focused on how much an old rival like Russian President Vladimir Putin stands to gain.

“Of course it would be massively concerning if it was the act of a foreign, hostile state,” Hunt told The Sun.

UK politicians have rallied behind the embattled ambassador and bristled at the thought of Trump simply shoving their man out of Washington.

Whether Darroch can still perform his duties depends on what Trump actually meant.

Darroch has already been taken off one White House dinner guest list.

But the UK envoy will be more concerned about maintaining his private contacts and talking to those in Trump’s inner sanctum.

If Trump means “the whole White House staff is closed to you, including the national security adviser, that would be much more serious,” Britain’s former US envoy Christopher Meyer said.

UK diplomats worry that the publication of what Downing Street described as Darroch’s “unvarnished” views will put off others from reporting similarly delicate matters.

“The damage is to the confidence of civil servants to put their frank thoughts to ministers,” the Foreign Office’s former permanent under-secretary, Peter Ricketts, wrote in The Guardian.

Ricketts also expressed worry that “Britain’s reputation as a country that knows how to keep its secrets” might be hurt.

Hunt agreed that it was “very important” that UK ambassadors all over “continue to give us their frank assessments”.

The scandal piles on the pressure for Johnson, Britain’s presumptive premier, to either bow to Trump’s pressure or stick by London’s envoy.

“For Boris Johnson, removing Darroch swiftly from office would be seen as a humiliating cave-in to a bullying foreign power,” the Politico site wrote.

“But voicing support for the beleaguered ambassador risks damaging relations with Trump from the outset.”

The choice is made all the more important by the next ambassador’s role in negotiating a new US trade agreement that can mitigate the potential damage of Britain’s EU split.

The “special relationship” term has always been more widely used in Britain than it has in the US, a superpower that also enjoys “special” ties with countries such as Israel and Canada.

“The relationship with Washington is based on strong and deep shared interests,” former under-secretary Ricketts wrote.

“Those are unchanged by the leaks.”