The US and Nato will withdraw all troops from the country within 14 months under an new agreement if the Taliban meets commitments to prevent terrorism.
America would initially reduce its forces in Afghanistan to 8,600 within 135 days of the US-Taliban agreement, which was being signed in the Qatari capital of Doha.
The US and Afghan governments said in a joint statement: “The coalition will complete the withdrawal of their remaining forces from Afghanistan within 14 months following the announcement of this joint declaration and the US-Taliban agreement … subject to the Taliban’s fulfilment of its commitments under the US-Taliban agreement.”
Jens Stoltenberg, secretary general of Nato, said the organisation “supports this peace deal” and was prepared to reduce the number of troops in the country.
However he said Nato would increase its presence again should the situation deteriorate, adding: “Peace is long and hard and we have to be prepared for setbacks and spoilers.”
The peace agreement aims to bring an end to 18 years of bloodshed in Afghanistan, and allow US troops to return home from America’s longest war.
President George Bush ordered the US-led invasion of Afghanistan in response to the 11 September attacks in 2001.
It only took a few months to topple the Taliban and send Osama bin Laden and top al Qaeda militants scrambling across the border into Pakistan, but the war dragged on for years as the United States tried to establish a stable, functioning state in one of the least developed countries in the world.
The Taliban regrouped, and currently holds sway over half the country.
US secretary of state Mike Pompeo arrived in Qatar from Washington on Saturday to witness the signing of the historic deal by US special envoy Zalmay Khalilzad and Taliban political chief Mullah Abdul Ghani Baradar.
Mark Esper, the US defence secretary, meanwhile travelled to Kabul on a visit that officials and experts said was aimed at reassuring the Afghan government about the United States’ commitment to the country.
The US embassy in Kabul said it was a “monumental day for Afghanistan”, adding in a post on Twitter: “It is about making peace and crafting a common brighter future. We stand with Afghanistan.”
Hours before the deal, the Taliban ordered all its fighters in Afghanistan “to refrain from any kind of attack … for the happiness of the nation”.
Zabiullah Mujahid, a spokesman for the hardline Islamist group, said: ”The biggest thing is that we hope the US remain committed to their promises during the negotiation and peace deal.”
He added that it was “irritating and provocative” that foreign military aircraft continued to fly over Taliban territory, but militia fighters were following the order to stand down.
The British foreign secretary, Dominic Raab, said: “These agreements mark a significant moment in the pursuit of peace in Afghanistan.
“The current reduction in violence is welcome and I hope it will be maintained, but meaningful negotiations between the Afghan leadership and the Taliban are the real prize, and I hope this opportunity will be seized.
“The only way to achieve lasting peace in Afghanistan is through a political solution.”
More than 2,400 US troops have been killed in the war since 2001, along with more than 450 UK troops and tens of thousands of Afghan government soldiers, Taliban fighters and civilians.