US and Taliban officials have agreed in principle to the framework of a deal that could pave the way for peace talks in Kabul and ultimately the withdrawal of American troops from Afghanistan, raising hopes of a breakthrough in the country’s 17-year conflict.

Under the terms of the draft framework, the insurgents would promise to stop Afghan territory being used by terrorists. The US special envoy, Zalmay Khalilzad, confirmed the existence of the draft in an interview with the New York Times (NYT).

The draft, thrashed out in lengthy talks in Qatar that ended on Saturday, requires the Taliban to agree to a ceasefire and to talk directly with the US-backed Afghan government led by President Ashraf Ghani – two conditions which the Taliban have not agreed to.

If the talks led to a full deal, US troops would be withdrawn from Afghanistan within 18 months.

The optimism expressed by Khalilzad in his NYT interview may yet be dashed by dissent within the Taliban or opposition from the government in Kabul. Ghani immediately expressed his doubts about a rushed process from which his ministers had been excluded.

Sign up for the US morning briefing

Last week Ghani acknowledged that more than 45,000 members of the Afghan security forces had died since 2014, a far higher number than previously thought. The Taliban run more than half the country and have not slowed the rate of attacks during winter, which is normally a lull. The group is increasingly confident that the US is losing the will to continue the war.

Khalilzad said: “The Taliban have committed, to our satisfaction, to do what is necessary that would prevent Afghanistan from ever becoming a platform for international terrorist groups or individuals. We felt enough confidence that we said we need to get this fleshed out, and details need to be worked out.”

Working groups would iron out details on the timeline of the withdrawal, but Khalilzad said there had been no discussions about the possibility of a Taliban role in a transitional government. The US stressed that the agreement was conditional on a ceasefire and direct talks between the Afghan government and the Taliban. Pakistan would be expected to play a key role in persuading the Taliban to show flexibility.

Khalilzad returned to Afghanistan on Sunday to brief the Ghani government in Kabul after the six days of talks in Doha.

In an address to the Afghan people responding to the talk of a breakthrough, Ghani recalled his country had struck deals with the Taliban before only to see the terms violated. “We want peace quickly, we want it soon, but we want it with prudence,” he said. “Prudence is important so we do not repeat past mistakes.”

The acting US defence secretary, Patrick Shanahan, said he was encouraged by the progress of the talks but had not yet been tasked with planning a full withdrawal of troops. “Really the takeaway right now [is]: it’s encouraging,” Shanahan told reporters outside the Pentagon.

There appear to have been few, if any, assurances from the Taliban about the kind of society Afghanistan would become, including about issues such as the future of girls’ education and women’s role in wider society.

Ghani is nervous that the US president, Donald Trump, is so intent on withdrawing his troops from the country that he will sideline the Afghan government in the process, and even try to force Ghani’s ministers to share power with the Taliban in a transitional government.

The Taliban refused to let the Ghani government, which it regards as a US puppet, accompany the Americans in the Doha talks. The Americans regarded the talks as serious since one of the most senior officials in the Taliban movement, Mullah Abdul Ghani Baradar, was chief negotiator.

Ghani is running for a second five-year term in elections now scheduled for July.

The talks in Doha, Qatar, lasted much longer than planned and longer than any previous attempt to end the Afghan conflict.

US nuclear weapons: first low-yield warheads roll off the production line Read more

Saudi Arabia, Pakistan and the United Arab Emirates took part in the last round of talks in December, but the Taliban insisted this time that only the US attended.

The US sent troops to Afghanistan in the wake of the 9/11 attacks on New York and Washington in 2001, and at the peak of the deployment had more than 100,000 troops in the country. It withdrew most of its forces in 2014, but still keeps about 14,000 troops there as part of a Nato-led mission aiding Afghan security forces and hunting militants.

Khalilzad’s comments gave weight to reports last week that the Taliban had agreed to oppose al-Qaida and Islamic State in Afghanistan.

The US invasion of 2001 was driven by the Taliban’s harbouring of al-Qaida, but more than 17 years later the jihadist group appears diminished in the region. Isis, however, is a growing and potent presence in Afghanistan, where it is fighting a fierce turf war with the Taliban in some areas.