The Prime Minister paid tribute to the “valour and sacrifice” of the British troops who had served in the struggle against the Taliban.
It follows the announcement in April by US President Joe Biden that he was finally ending the US military presence in the country.
His decision to bring home the remaining 2,500 American troops by the next anniversary of 9/11 in September effectively meant the end of the international military mission – including the return of the last 750 UK military trainers in the country.
Making a statement in the Commons, the Prime Minister admitted there could "never be a perfect moment" to withdraw, but it was "never intended to be permanent".
Mr Johnson said most of the remaining 750 UK military trainers with the Nato mission have already left the country.
He said: “We are not about to turn away nor are we under any illusions about the perils of today’s situation and what may lie ahead.
“We shall use every diplomatic and humanitarian lever to support Afghanistan’s development and stability.
“Of course we will continue to work alongside our Afghan partners against the terrorist threat.”
More than 450 British troops have died during the conflict since 2001.
There are fears the departure of foreign forces will leave the government of President Ashraf Ghani vulnerable in the face of a Taliban advance, undoing the work of the last two decades.
Head of the Armed Forces General Sir Nick Carter warned the situation is “pretty grim” with half the country’s rural districts now in the hands of the Taliban.
In a briefing for journalists, he warned there is now a danger of “state collapse”.
He added: “That’s where you would see a culture of warlord-ism, and you might see some of the important institutions, like the security forces, fracturing along ethnic, or for that matter tribal, lines.
“If that were to happen, I guess the Taliban would control part of the country, but of course they wouldn’t control all of the country.”
Labour’s Angela Rayner warned “we simply cannot wash our hands or walk away” from Afghanistan.
Responding in the Commons, the Deputy Labour leader said: “We have supported improvement in security, in governance, in economic development and as the PM said in advancing the rights of women and education for girls. Yet these gains have not been secured.
“The Taliban are making gains on the ground and serious questions remain about the future stability of Afghanistan.
" A security threat remains for the wider world, including to the UK. And nobody wants to see British troops permanently stationed in Afghanistan, but we simply cannot wash our hands or walk away.”
Conservative MP Nusrat Ghani warned women and girls in Afghanistan would now be “lambs to the slaughter”.
She told the Commons: “I was in Afghanistan post-9/11 and the women and girls are telling me now that under Taliban, regardless of any peace settlements, they are lambs to the slaughter, their schools will be closed, their clinics will be closed.”