Theresa May said Sir Kim's departure was "a matter of deep regret" after the ambassador said it was "impossible" for him to continue.
Meanwhile, one minister said Boris Johnson had thrown Sir Kim "under a bus" by not fully supporting him.
President Trump said on Monday that the US would not deal with Sir Kim.
The US president had branded him "a very stupid guy" after emails emerged where the ambassador had called his administration "clumsy and inept".
In a letter to the Foreign Office, Sir Kim said he wanted to end speculation about his position: "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."
The leak was described as "malicious" by Sir Simon McDonald, permanent under secretary and head of the diplomatic service, who told Sir Kim: "You are the best of us."
He told the Commons' foreign affairs committee it was the first time in his career that a head of state had refused to work with a British ambassador.
Mrs May said Sir Kim had had the full backing of the cabinet and had given a "lifetime of service" to the UK, for which he was owed an "enormous debt of gratitude".
"Good government depends on public servants being able to give full and frank advice", she said.
She spoke of the importance of "defending our values and principles particularly when they are under pressure".
Read More (...)