Boris Johnson, frontrunner to become Britain’s next prime minister, was accused of throwing the country’s ambassador to the US “under a bus”, after Kim Darroch quit following a bitter clash with President Donald Trump.

Sir Kim on Wednesday said that the stand-off with Mr Trump — sparked by the leaking of a cache of diplomatic cables in which he called the White House “inept” and “dysfunctional” — had made his job “impossible”.

But he told friends he took the final decision to resign after he watched Mr Johnson refuse to support him in a live television debate, and fail to commit to keeping him in Washington. “It was a factor,” confirmed one friend.

Alan Duncan, a Foreign Office minister, said Mr Johnson had “thrown our ambassador under a bus”, adding that the behaviour of the Tory leadership frontrunner was “contemptible”.

Civil service leaders said Mr Johnson’s failure to back Britain’s top ambassador would have a chilling effect on the willingness of officials to give frank advice to their political masters.

It should not have ended like this. He has been taken out by an act of political sabotage. What does this say about the state of our country?

But supporters of Mr Johnson hit back, claiming it was inevitable that Sir Kim would be forced out of office after the disclosure of his cables prompted Mr Trump to blackball the ambassador, calling him “wacky” and “pompous”.

Mr Johnson’s allies said the blame should lie with the leaker of the papers and claimed that officials in the Foreign Office were launching a “politically motivated” campaign to try to derail the leadership ambitions of the pro-Brexit former foreign secretary.

Mr Johnson said in the leadership debate that he did not want to prejudge who would be Britain’s ambassador in Washington if he became prime minister; that decision could now be taken by Theresa May, the outgoing premier. Her aides declined to say whether she would appoint Sir Kim’s successor before leaving office on July 24.

The White House declined to comment. But Sir Kim’s departure underscored the tough position many US allies find themselves in when dealing with Mr Trump, who has been quick to criticise countries from the UK and Germany to Japan and South Korea.

The dispute comes in the middle of a Conservative leadership contest, but is unlikely to obstruct Mr Johnson’s apparently clear route to Downing Street. Many Tory activists have already voted and some supporters of Mr Johnson’s rival, current foreign secretary Jeremy Hunt, admitted that Tory activists were unlikely to be unduly worried about a high-level diplomatic row.

Peter Ricketts, a former head of the Foreign Office, wrote on Twitter that Sir Kim had been an outstanding public servant over 42 years. “It should not have ended like this. He has been taken out by an act of political sabotage. What does this say about the state of our country?”

David O’Sullivan, who served as EU ambassador to Washington until March and is a friend of Sir Kim, said the UK ambassador had been “deliberately and maliciously stabbed in the back” with the leaks, which he said were “further evidence of the toxic impact of the Brexit debate on the UK’s most cherished institutions”.

Emily Thornberry, shadow foreign secretary, said Sir Kim had been “bullied out of his job” by Mr Trump’s tweets and Mr Johnson’s remarks during Tuesday night’s debate. “It makes a laughing-stock out of our government, and tells every one of Britain’s brilliant representatives abroad that the next Tory prime minister will not stand up for them,” she said.