The US and Taliban militants have signed a “comprehensive peace agreement” to end fighting in Afghanistan after more than 18 years of conflict.
The US and NATO allies have agreed to withdraw all troops within 14 months if the militants uphold the deal.
President Donald Trump said the US was “working to finally end America’s longest war and bring our troops back home”.
Talks between the Afghan government and the Taliban are due to follow.
Secretary of State Mike Pompeo and the Taliban leaders attended the signing ceremony in Doha in Qatar.
Under the agreement, the Talibans also agreed not to allow al-Qaeda or any other extremist group to operate in the areas they control.
The US invaded Afghanistan after the 9/11 attacks in New York by the Afghanistan-based al-Qaeda group.
More than 2,400 US troops have been killed during the conflict. About 12,000 are still stationed in Afghanistan. President Donald Trump has promised to put an end to the conflict.
The deal was signed by US special envoy Zalmay Khalilzad and Taliban political chief Mullah Abdul Ghani Baradar with Mike Pompeo as a witness.
In a speech, Mike Pompeo urged the militant group to “keep your promises to cut ties with al-Qaeda”.
Mullah Abdul Ghani Baradar said he hoped Afghanistan could now emerge from four decades of conflict.
Meanwhile Defense Secretary Mark Esper was in the Afghan capital Kabul alongside Afghanistan’s President Ashraf Ghani – whose government did not take part in the US-Taliban talks.
Mark Esper said: “This is a hopeful moment, but it is only the beginning. The road ahead will not be easy. Achieving lasting peace in Afghanistan will require patience and compromise among all parties.”
He said the US would continue to support the Afghan government.
President Ghani said Afghanistan was “looking forward to a full ceasefire”. The government said it was ready to negotiate with the Taliban.
Within the first 135 days of the deal the US will reduce its forces in Afghanistan to 8,600, with allies also drawing down their forces proportionately.
The move would allow President Donald Trump to show that he has brought troops home ahead of the US presidential election in November.
The deal also provides for a prisoner swap. Some 5,000 Taliban prisoners and 1,000 Afghan security force prisoners would be exchanged by March 10, when talks between the Taliban and the Afghan government are due to start.
The US will also lift sanctions against the Taliban and work with the UN to lift its separate sanctions against the group.