The UK will evacuate the "vast bulk" of its embassy staff in the coming days as the Taliban continues to advance.
The prime minister said there was "no military solution" after an emergency Cobra meeting on Friday afternoon.
On Thursday, the UK said it would send 600 troops to help evacuate British nationals and former Afghan staff.
Thousands of civilians have fled the Taliban onslaught, heading for the capital of Kabul.
The World Food Programme has warned that food shortages are "dire", while the UN has urged Afghanistan's neighbours to keep their borders open.
The militants now control about a third of Afghanistan's provincial capitals, including Herat, Ghazni and Lashkar Gar.
Mr Johnson insisted there was no military solution following the gains made by the Taliban in recent days and said that a team of Home Office officials would be sent to step up efforts to relocate Afghans who worked for British forces in the country.
"It is very difficult obviously, but I think the UK can be extremely proud of what has been done in Afghanistan over the last 20 years," he said.
The prime minister said that thanks to the efforts of the UK armed services there had been no al-Qaeda attacks on the West for "a very long time".
He also added that three million girls and young women in Afghanistan had been educated who otherwise would not have been, during the last 20 years.
"I think we've got to be realistic about the abilities of the UK or any power to impose a military solution, a combat solution in Afghanistan," Mr Johnson said.
"What we certainly can do is work with all our partners in the region and around the world who share an interest with us in preventing Afghanistan from once again becoming a breeding ground for terror."
Earlier, Lisa Nandy, Labour's shadow foreign secretary, told BBC Radio 4's World At One programme there was "far more" the UK could do to support the people of Afghanistan and accused the government of "hiding".
She warned the government that cross-party MPs could push to recall Parliament to hold the government to account if it did not show a clear strategy.
Ms Nandy said that people in the country felt "abandoned" and were looking to the US and UK for "a level of leadership".
Her concerns were echoed by former Conservative Defence Minister Johnny Mercer, who served in Afghanistan.
He described the situation in the country as a "world tragedy" which would have repercussions "for years to come".
Lib Dem leader Sir Ed Davey has also backed the idea of recalling Parliament "given the tragedy unfolding before our eyes" and called on the UN to deploy peacekeepers.
Earlier, Defence Secretary Ben Wallace acknowledged that the country could be "heading towards civil war".
He blamed former US President Donald Trump's "rotten deal" with the Taliban in 2020 for the withdrawal.
The UK government has launched "Operation Pitting", to help evacuate British nationals, former UK staff and others who are eligible to relocate to the UK.
Mr Wallace said around 600 troops were being sent to Afghanistan to ensure the safe return of about 500 Foreign Office and other UK government officials, along with around 3,000 British citizens working in other roles, such as security guards for aid agencies.
About 2,000 Afghan interpreters and "other people we have an obligation to" would also be transported to the UK, he said, joining some 3,000 who had already been taken out of the country.
RAF aircraft could be used if needed and the Home Office would also be deploying a small team of officials to assist with processing new visas, the Ministry of Defence said.
The US said it would have the bulk of the 3,000 troops it is sending to assist with evacuation in place by the end of the weekend. Pentagon spokesman John Kirby added that the US military was "certainly concerned about the speed with which the Taliban is moving".
Nato said it had discussed the situation on Friday and would aim to support the Afghan government and security forces "as much as possible".
Secretary General Jens Stoltenberg said the Taliban would not be recognised by the international community if it took the country by force, adding that there was deep concern about reports of serious human rights abuses.
Wendy Rayner, whose husband Peter died in action in Helmand province in 2010, said the withdrawal undermined the sacrifice of soldiers who had lost their lives.
"My husband died to give them a better life, and by them not having a better life, it's taken away his fight," she told the BBC.
"All these young people in Afghanistan that are having their families slaughtered because nobody cares, because we've just left them in the lurch - it's just going to create another terror threat. They're going to hate us and I don't blame them."
Mr Johnson said he did not think the sacrifices made by British forces were "in vain".
"I believe it was right, it was worth it and what we must do now is not turn our backs on Afghanistan," he said.