Most UK troops now out of Afghanistan: Johnson
"All British troops assigned to NATO's mission in Afghanistan are now returning home... I will not disclose the timetable of our departure, but I can tell the House that most of our personnel have already left," he said in a statement to MPs.
"But the threat that brought us to Afghanistan in the first place has been greatly diminished by the valour and the sacrifice of the armed forces of Britain and many other countries," he said.
"We are safer because of everything they did."
The conflict has cost the country around £40 billion ($55 billion, 46.7 billion euros).
In 2014, the British mission in Afghanistan, centred around the restive southern province of Helmand, shifted from a combat operation to one focused on supporting Afghan national forces, with the help of around 750 troops.
In the capital Kabul, fighting raged on Thursday between the Taliban and government forces.
The government flew hundreds of commandos into Qala-i-Naw, in the northwestern province of Badghis, the first provincial capital to face an all-out assault by the Taliban since the US stepped up its troop withdrawal.
Johnson demanded that the Taliban abide by its commitments to a peace deal signed last year.
"I am sure they will be aware there is no military path to victory for the Taliban," he said.
"There must be a peaceful and a negotiated settlement for the political crisis."