The United States has signed a peace agreement with the Taliban aimed at ending America’s longest war and bringing troops home from Afghanistan.

The historic deal, signed by chief negotiators from the two sides and witnessed by US secretary of state Mike Pompeo, could see the withdrawal of all American and allied forces in the next 14 months and allow President Donald Trump to keep a key campaign pledge to extract the US from “endless wars”.

But it could also easily unravel, particularly if the Taliban fail to meet their commitments.

At the White House, Mr Trump told reporters the US deserves credit for having helped Afghanistan take a step toward peace. He spoke cautiously of the deal’s prospects for success and warned the Taliban against violating their commitments.

“We think we’ll be successful in the end,” he said, referring to all-Afghan peace talks and a final U.S. exit. He said he will be “meeting personally with Taliban leaders in the not-too-distant future,” and described the group as “tired of war”.

He did not say where or why he plans to meet with Taliban leaders. He said he thinks they are serious about the deal they signed but warned that if it fails, the US could restart combat.

“If bad things happen, we’ll go back” in with military firepower, Mr Trump said.

Mr Pompeo was similarly cautious.

Speaking in the Qatari capital of Doha, Mr Pompeo said: “Today, we are realistic. We are seizing the best opportunity for peace in a generation.

Mike Pompeo
US secretary of state Mike Pompeo (Carolyn Kaster/AP)

“Today, we are restrained. We recognise that America shouldn’t fight in perpetuity in the graveyard of empires if we can help Afghans forge peace.”

Under the agreement, the US would reduce its forces to 8,600 from 13,000 in the next three to four months, with the remaining US forces withdrawing in 14 months. The complete pullout would depend on the Taliban meeting their commitments to prevent terrorism, including specific obligations to renounce al Qaida and prevent that group or others from using Afghan soil to plot attacks on the US or its allies.

The deal sets the stage for intra-Afghan peace talks to begin around March 10, with the aim of negotiating a permanent ceasefire and a powersharing agreement between rival Afghan groups.

Mr Pompeo said that “the chapter of American history on the Taliban is written in blood” and stressed that while the road ahead would be difficult, the deal represented “the best opportunity for peace in a generation”.

At a parallel ceremony in Kabul, US defence secretary Mark Esper and Afghan President Ashraf Ghani signed a joint statement committing the Afghan government to support the US-Taliban deal, which is viewed sceptically by many war-weary Afghans, particularly women who fear a return of repression under the ultra-conservative Taliban.

President George W Bush had ordered the US-led invasion of Afghanistan in response to September 11. Some US troops currently serving there had not yet been born when al Qaida hijackers flew two planes into the twin towers of the World Trade Centre, crashed another into the Pentagon and took down a fourth in Pennsylvania, killing almost 3,000 people.