Sir Kim had faced huge pressure following the leak of diplomatic dispatches in which he described the White House as "inept" and "dysfunctional".
The remarks prompted an angry backlash from US President Donald Trump, who called Sir Kim a "pompous fool" and a "very stupid guy" who had been foisted on the US.
In an extraordinary onslaught against an ally, Mr Trump also used a Twitter post to attack Theresa May over Brexit, accusing her of ignoring his advice and "going her own foolish way".
In a letter to Sir Simon McDonald, the permanent under secretary at the Foreign and Commonwealth Office, Sir Kim 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, Sir Simon wrote: “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.”