THE Tories have been hammered by Nicola Sturgeon for their “shameful” handling of the Kim Darroch controversy after it was revealed he would resign as UK ambassador to the United States.

A leak of sensitive diplomatic messages had shown that Darroch believed Donald Trump’s administration to be “inept”.

Downing Street had insisted Theresa May had “full faith” in the ambassador earlier this week after Trump said he will “no longer deal” with Darroch and criticised the Prime Minister for making a “mess” of Brexit.

Asked about the issue during a Tory leadership TV debate last night, Foreign Secretary Jeremy Hunt said Darroch would remain in his post until he was due to resign at the end of the year.

Rival Boris Johnson said: “I have a very good relationship with the White House ... and it is very important we have a close friendship, a close relationship with the United States.”

READ MORE: Donald Trump takes aim at Theresa May in ambassador leak row

But now, in a letter to Sir Simon McDonald, the permanent under secretary at the Foreign and Commonwealth Office, Darroch has announced his resignation.

He cited a desire to “put an end to that speculation”.

Sturgeon lambasted the Tory government for its handling of the affair and claimed the ambassador had been “forced out”.

“It is shameful that Kim Darroch has effectively been forced out for doing the job that diplomats are appointed to do,” The First Minister tweeted.

“Boris Johnson’s failure last night to stand up for him – and stand up to the behaviour of Donald Trump – spoke volumes.”

In his resignation letter, Darroch wrote: "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. 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.

"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.

"I am grateful to all those in the UK and the US, who have offered their support during this 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.

"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 world. I will leave it full of confidence that its values remain in safe hands."

In response, McDonald said: "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.

"The Prime Minister, Foreign Secretary and whole of the public service have stood with you: you were the target of a malicious leak; you were simply doing your job. 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.

"I want to stress my deep appreciation for all you have done over the last four decades. In a series of demanding roles – including National Security Adviser and Permanent Representative to the European Union – you have loyally served the government of the day without fear or favour. We have been lucky to have you as a friend and colleague. You are the best of us."