In a bid to end the 18-year-old war in Afghanistan, the United States and Taliban representatives officially signed the historic peace deal on Sunday in the Qatari capital Doha.

Under the signed deal, the United States and its allies will withdraw all their forces from the war-torn country within 14 months if the Taliban abide by an agreement, Washington and Kabul said during the joint declaration.

After an initial reduction of troops to 8,600 within 135 days of Saturday's signing, the US and its partners "will complete the withdrawal of their remaining forces from Afghanistan within 14 months... and will withdraw all their forces from remaining bases," the declaration stated.

The deal was signed by US special envoy Zalmay Khalilzad and Taliban political chief Mullah Abdul Ghani Baradar in presence of US Secretary of State Mike Pompeo and Afghan President Ashraf Ghani.

Representatives from 26 countries including Pakistan Foreign Minister Shah Mehmood Qureshi and India's foreign secretary have also witnessed the signing of the landmark deal.

The agreement is expected to lead to a dialogue between the Taliban and the Kabul government that, if successful, could ultimately see an end to the grinding 18-year old conflict.

The historic deal with the Taliban "would pave way for peace in Afghanistan," President Ashraf Ghani said during the joint declaration.

Also read: US State Secretary Pompeo sees 'significant reduction' in Afghanistan violence

The US also promised to help Afghanistan in fighting Al-Qaeda in the country; while it also sought an assurance from the Taliban to not use the Afghan soil for terrorism.

The United States also ensured political independence to Afghanistan and not carry out any attack in the south-Asian country.

'We will make sure that Afghanistan never again serves as the base of international terrorism', US State of Secretary Mike Pompeo said in his address.

"Keep up your promises to not side with Al-Qaeda and to defeat Islamic State", Pompeo said while referring to the Taliban.

In pics: How India changed its gameplan on tackling the Taliban in Afghanistan

"Afghanistan people have rejoiced", Pompeo added.

Meanwhile, US Defence Chief said that Washington "will not hesitate to nullify" the deal if Taliban failed to hold its promises as per the deal.

On a visit to Kabul, Mark Esper said, "Should the Taliban fail to honour their commitments they will forfeit their chance to sit with fellow Afghans and deliberate on the future of their country."

In pics: Afghanistan since the Taliban regime fell in 2001

"Moreover the United States would not hesitate to nullify the agreement," he added.

The signing comes after a week-long, partial truce that has mostly held across Afghanistan, aimed at building confidence between the warring parties and showing the Taliban can control their forces.

Since the US-led invasion that ousted the Taliban after the September 11, 2001 attacks, America has spent more than $1 trillion in fighting and rebuilding in Afghanistan.

About 2,400 US soldiers have been killed, along with unknown tens of thousands of Afghan troops, Taliban fighters and Afghan civilians.

(With inputs from agencies)