A peace deal between the United States and its once sworn enemy the Taliban has been sealed in twin ceremonies, in which the US has agreed to wind down the war in Afghanistan after more than 18 years of fighting that turned into the longest conflict in American history, and to withdraw all of its troops from Afghanistan.

In the historic signing ceremony with the top US diplomat and the Taliban's second highest-ranking leader, the U.S. and the militant group agreed to begin to end America's longest war. US Secretary of State Mike Pompeo met a Taliban delegation during a historic moment which they shared a stage in Qatar's capital Doha. Pompeo, who called it "a momentous day", gave a list of pointers to the Taliban to follow to ensure success.

Included in the deal are the following key clauses:

Complete withdrawal of US and NATO troops from Afghanistan in 14 months

Afghan govt to engage with United Nation Security Council to remove Taliban members from sanctions list by 29 May

US to reduce troops in Afghanistan to 8,600 within 135 days of - contingent on the Taliban's fulfilment of its commitments under the agreement

US to refrain from use of force against territorial integrity of Afghanistan.

US will not intervene in Afghanistan's domestic affairs

US commits to seek annual funds to train, advice, equip Afghan security forces

The deal - signed by US special envoy Zalmay Khalilzad and Taliban political chief Mullah Abdul Ghani Baradar - agrees to the complete withdrawal of US and NATO troops within 14 months, contingent on Taliban following through with its own side of the deal. The US has also agreed to refrain from the use of force against Afghanistan or intervening in its domestic affairs. It has also committed to seeking annual funds to train, advise and equip Afghan security forces.

Mike Pompeo meets Taliban representatives in Doha to sign the agreement

The agreement allows the US to immediately begin withdrawing some of its roughly 13,000 troops in Afghanistan, fulfilling a key campaign promise of President Donald Trump to start getting the U.S. out of “endless wars.” But it leaves many key details - including a lasting peace agreement between the Taliban and the Afghan government, as well as the rights of women - for future negotiations. The deal - which followed a seven-day reduction in violence - is also expected to pave the way toward direct talks between Taliban officials and Afghan leaders in Oslo next month, according to Bloomberg.

Barring complications, US troop levels are expected to decline to about 8,600 within 135 days, with all troops being withdrawn within 14 months. Further declines depend on the Taliban fulfilling their agreement to engage in talks with Afghan officials and confront terrorists, according to U.S. officials.

In exchange for the initial U.S. troop drawdown, the Taliban pledge to sit down to peace negotiations with other Afghans to cut ties with all terrorist groups like al-Qaida - which the Taliban harbored ahead of the Sept. 11 attacks, prompting a US invasion and over 18 years of war, and prevent Afghan territories from becoming militant havens. Despite almost two decades of war and $900 billion in spending by the US, the Taliban are at their strongest since being ousted by American forces in late 2001, after the group refused to hand over al-Qaeda leader Osama bin Laden following the Sept. 11 terror attacks.

Speaking at a parallel ceremony in Kabul, Afghanistan's president Ashraf Ghani said: "All the people of Afghanistan are looking forward to a permanent peace." He said that "today can be the moment of overcoming the past" and called for a moment of silence "in honour of our mutual fallen heroes".

"The tragedy of 9/11 brought us together. Mutual sacrifice created human bonds between us. Mutual interest, your security and our freedom, sustains our relationship in mutual respect, which has made us partners", he said.

Calling the relationship "transparent" he said: "NATO and US partners have spared neither blood nor treasure for attaining the goals of the partnership. We ask you to thank the veterans, especially the gold star families, for their service. Our sacrifice has been immense... children, youth in their prime, and men and women in all ages in all walks of life, whose lives have been taken away by senseless acts of violence in terror and public spaces."

And he said: "We have the political will and the capacity to make peace because of the resilience of our society, the dynamism of our economy and the capability of our state."

* * *

After over a year and a half of negotiations, details of the final agreement were finally released on Saturday, although there are annexes that will not be released, according to senior administration officials, who said they do not include any U.S. commitments, only enforcement mechanisms.

While many of the steps in the deal are conditioned on actions from both sides, there are some immediate impacts as the ink dries in Doha, Qatar, where chief U.S. negotiator Zalmay Khalilzad, his deputy Molly Phee and their team have spent over a year and a half negotiating with the Taliban's representatives.

A week-long deal to reduce violence will continue, as the US immediately begins to draw down its approximately 13,000 troops in Afghanistan to 8,600, according to Defense Secretary Mark Esper and other senior administration officials. That withdrawal will take months to complete, but U.S. officials, including Gen. Scott Miller, commander of U.S. and NATO forces in Afghanistan, have said that new number is still sufficient to carry out their mission.

Any withdrawal of U.S. forces beyond that is contingent on the Taliban meeting its commitments, according to the deal.

There is "an aspirational timeline for withdrawal that is entirely conditions-based, and it will depend on their performance as we judge their performance," a senior administration official said. Explicitly, withdrawal is tied to the Taliban meeting its counterterrorism commitments - to repudiate al-Qaida and other terrorist groups and take steps to demonstrate that.

"People are concerned about the historic relationship between the Taliban and al-Qaida. We think think this is a decisive and historic first step in terms of their public acknowledgement that they are breaking ties with al-Qaida," a senior administration official told ABC News.

There will be verification mechanisms in place to ensure that happens, the official added, including "our military and other asset presence on the ground." In exchange, they said, the U.S. will eventually start to deconstruct the "edifice" of economic and diplomatic pressure like sanctions.

But any further U.S. troop reduction is also tied to the Taliban's behavior in Afghan peace negotiations, according to the senior officials, although it is not dependent on any particular outcome of that process.

"If the political settlement fails, if the talks fail, there is nothing that obliges the United States to withdraw troops," said a second senior administration official, before adding that President Donald Trump still has the "prerogatives as commander-in-chief" to withdraw U.S. forces as he sees fit.

Aiming for March 10, those peace negotiations will bring together the Taliban and representatives of Afghanistan, including government officials, civil society leaders and women, the senior officials said, to determine the future Afghan government and a "road map" for the country. But government officials will attend in a "private" capacity, as the Taliban still refuses to recognize the government or the constitution -- a concession that has angered many Afghan officials.

Esper is in Kabul to sign a joint declaration with President Ashraf Ghani and his rival and chief executive Abdullah Abdullah to reassert US support for the Afghan government and commit Ghani, Abdullah, their supporters and others to backing the next steps. Expected to take place in Oslo, Norway, the negotiations will be facilitated by the U.S., along with the United Nations, Norway, Germany, Indonesia and Uzbekistan, among others, the first senior official said.

Both senior officials cautioned those talks could be delayed, especially as post-election fighting between Ghani and Abdullah continues. Khalilzad will return to Kabul after the signing ceremony to push them to select an inclusive delegation to the negotiations, but it may prove difficult as Abdullah continues to claim to have won the presidency, five months after the votes were cast and 11 days after Ghani was declared the winner despite concerns over the count.

U.S. military commanders long ago assessed that the war would be unwinnable absent the presence of tens of thousands of more troops and a broad political accord. At its peak the U.S. had over 100,000 troops based in Afghanistan, but peace remained elusive in a country long known as the “graveyard of empires.”

More than two decades before U.S. forces arrived, Afghans had to contend with the Soviet Union’s invasion, a searing experience that led to a humiliating defeat for Moscow. As the Taliban consolidated power in the late 1990s, they became known for enforcing an extreme version of fundamentalist Islam that denied girls the right to an education and banned women from working.

* * *

Ahead of the signing of the Doha deal, U.S. officials described the agreement as the beginning of an effort to reach a broader political solution to a war that has spanned three U.S. presidencies and killed or injured more than 100,000 Afghans over the past decade alone, while costing the lives of over 2,400 American troops. Even as Taliban and U.S.-backed Afghan forces have fought to a stalemate, Islamic State terrorists gained a foothold in the country.

"Everyone is tired of war,” said Masood Mahfuz, a 42-year-old Afghan whose brother was killed in a Taliban bombing three years ago. “We are thirsty for peace. The only way is to make peace with the Taliban and forget the past."

The signing ceremony Saturday came only after a week-long truce to reduce violence across the country was deemed successful. The Taliban agreed not to undertake major attacks, while the U.S. and Afghan security forces pledged to hold any airstrikes or raids on Taliban facilities, according to the second senior official, who said the reduction showed the Taliban had "both the commitment and the capability to enforce" that kind of truce.

With the deal signed, there will be a further reduction of violence, the first senior official said, that is supposed to last as the Afghan peace negotiations take place. Both senior administration officials said the U.S. will push the parties to extend that reduction into a complete ceasefire across the country as quickly as possible -- and for the protection of women's and minorities' rights, which critics say should have been a precondition all along.

But Secretary of State Mike Pompeo said Tuesday, "Our mission set there has been much broader than that," later adding "the Afghans will drive the solution," including on women's rights. Senior officials have said the U.S. will use its financial assistance as leverage to ensure those protections make it into the new government.