The United States has today signed a peace agreement with Taliban militants aimed at bringing an end to 18 years of bloodshed in Afghanistan and allowing US troops to return home from America's longest war.

Under the agreement, the US will begin withdrawing thousands of troops in exchange for Taliban commitments to prevent Afghanistan from being a launchpad for terrorist attacks. If the Taliban meet their commitments, all US troops would leave in 14 months.

The peace agreement is expected to lead to a dialogue between the Kabul government and the Taliban that could see the end of the Afghan war.

However, the position of the Afghan government, which has been excluded from direct US-Taliban talks, remains unclear. The country is also currently gripped by a fresh political crisis amid contested election results.

The signing comes after a week-long, partial truce that has been largely successful across the country. It was aimed at building confidence between the warring parties and showing that the Taliban can control their forces.

The next step is for the US to reduce its troops to 8,600 within 135 days of Saturday's signing and for the Taliban to uphold the US' counter-terrorism conditions.

President George W Bush ordered the US-led invasion of Afghanistan in response to the September 11 attacks. Some US troops currently serving there had not yet been born when the World Trade Center collapsed on that crisp, sunny morning that changed how Americans see the world.

It only took a few months to topple the Taliban and send Osama bin Laden and top al-Qaida 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 hold sway over half the country.

The US spent more than $750 billion, and on all sides, the war cost tens of thousands of lives lost, permanently scarred and indelibly interrupted. But the conflict was also frequently ignored by US politicians and the American public.

US Secretary of State Mike Pompeo arrived in the Qatari capital, Doha, on Saturday. He will stand with leaders of the Taliban, who harboured bin Laden and his al-Qaida network as they plotted, and then celebrated, the hijackings of four airliners that were crashed into lower Manhattan, the Pentagon and a field in western Pennsylvania, killing almost 3,000 people.