LONDON — Kim Darroch resigned on Wednesday as Britain’s ambassador to the United States after the leak of his candid observations on the Trump administration, a ferocious response from President Trump and the failure of the likely next prime minister, Boris Johnson, to support the British envoy.

Mr. Darroch submitted his resignation in a letter that said the situation was making it impossible for him to carry out his role. “Although my posting is not due to end until the end of this year, I believe in the current circumstances the responsible course is to allow the appointment of a new ambassador,” he wrote.

On Monday, Mr. Trump said the White House would no longer deal with Mr. Darroch after the leak of confidential emails written by the ambassador that had described the Trump administration as “clumsy and inept.” The president described the ambassador as “wacky,” a “very stupid guy” and a “pompous fool,” and called Prime Minister Theresa May “foolish” for ignoring his advice on Brexit.

The dispute has cast a shadow over ties between London and Washington and taken center stage in the Tory leadership contest to succeed Mrs. May as prime minister, which Mr. Johnson is heavily favored to win.