Sir Kim Darroch has resigned as British ambassador to the United Statesinfo-icon, as a diplomatic row between the two allies erupts.

"The current situation makes it impossible for me to carry out my role," said the diplomat, following the leak of unflattering remarks made about USinfo-icon President Donald Trumpinfo-icon.

"Since the leak of official documents from this embassy there has been a great deal of speculation surrounding my position and the duration of my remaining term as ambassador," he said in his resignation letter to Sir Simon McDonald, the foreign office's head of diplomatic service.

"I want to put an end to that speculation. The current situation is making it impossible for me to carry out my role as I would like."

The UKinfo-icon Foreign and Commonwealth Office confirmed the 65-year-old's resignation on Wednesday.

"That tranche of documents - diplomatic telegrams - was leaked to a British newspaper; it is assumed by either a politician or civil servant who is sympathetic to Donald Trump and wanted to embarrass the ambassador," said Al Jazeera's Laurence Lee from London.

Laurence Lee on why the ambassador felt he had to resign

"Trump then went full-bore against the UK, disinviting the veteran diplomat from several events and the administration cancelling an important meeting with UK trade minister Liam Fox.

"[Sir Kim] has been described as a very experienced and very capable diplomat. This has led to a flat spin of a diplomatic crisis."

Trump had on Monday launched a broadside against UK Prime Minister Theresa May and said the US would "no longer deal" with the British ambassador after the diplomat's assessment of the Trump administration as "inept" was leaked to the Daily Mail newspaper.

Twitterinfo-icon 'diplomacy'

Trump lambasted May's handling of Brexit on Twitter, saying she disregarded his advice.

"What a mess she and her representatives have created," he wrote. "I do not know the Ambassador but he is not liked or well thought of within the US. We will no longer deal with him."

"The good news for the wonderful United Kingdominfo-icon is that they will soon have a new Prime Minister."

Hours after Trump's tweet, May's spokesman reiterated Britaininfo-icon's position that the leak was unfortunate and said Darroch "continues to have the prime minister's full support".

The veteran diplomat wrote of his gratitude in his resignation. 

"I am grateful to all those in the UK and the US who have offered their support during these difficult few days. This has brought home to me the depth of friendship and close ties between our two countries. I have been deeply touched," read the ambassador's resignation letter.

"I am also grateful to all those with whom I have worked over the last four decades, particularly my team here in the US. The professionalism and integrity of the British civil service is the envy of the worldinfo-icon. I will leave it full of confidence that its values remain in safe hands."

Sir Simon McDonald - the top civil servant at the foreign office - replied: "On behalf of the Diplomatic Service, I accept your resignation with deep personal regret. Over the last few difficult days you have behaved as you have always behaved over a long and distinguished career, with dignity, professionalism and class... you were the target of a malicious leak; you were simply doing your job.

Trumps says he would 'no longer deal' with UK envoy

"I understand your wish to relieve the pressure on your family and your colleagues at the Embassy, I admire the fact that you think more of others than yourself. You demonstrate the essence of the values of British public service."

'Lifetime of service'

Prime Minister Theresa May told the House of Commons Sir Kim had "given a lifetime of service" to the UK. "Good governance depends on public servants being able to give full and frank advice," she said.

Foreign Secretary Jeremy Hunt said he was "deeply saddened" by the ambassador's decision to resign.

"He brought dispassionate insight and directness to his reporting to ministers in London," he said. "I am outraged that a selection of his reports should have been leaked."

Hunt is one of the two candidates to replace May as prime minister. In a TVinfo-icon debate on Tuesday night, Hunt had offered his support to the US ambassador - while his rival, Boris Johnson, refused to rule out firing the envoy.

"A move like this was probably always going to be inevitable," Professor Thom Brooks, dean at Durham Law School, told Al Jazeera. "His retirement wasn't due until the end of the year, but he's been pushed by events - by an angry White House.

"The White House will think this is good, they will probably take credit, being upset about these comments and then seeing the British do what they want them to do. On the other hand, it shows how weak the Conservative government is here."

Trump had called Sir Kim, a veteran diplomat, "wacky... a stupid man" and "a pompous fool".

"It's unpresidential to refer to people - especially ambassadors - in that way," said Brooks. "In the leaked documents the ambassador notes a White House that is dysfunctional and that has someone in President Trumpinfo-icon who has been erratic and unreasonable - and I think Trump's tweets highlight the correctness of the British ambassador's remarks.

"I think this is very worrying. The government has literally been rolling out the red carpet for Trump - all to get him to like some wonderful free trade deal, if only Brexit could get sorted. And all these things have been blowing up in their face. And other ambassadors will now know that they have to be careful with what they say, because if it's leaked, they won't get the support of their government."