The United States and the Taliban are poised to clinch a deal that would see the withdrawal of U.S. troops and the start of peace talks between the insurgents and the Afghan government. But the agreement will go ahead only if the Taliban abide by a pledge to reduce violence over a seven-day period, according to a Western official, an Afghan official and two former U.S. officials briefed on the talks.

The two sides have revived the same draft agreement that came close to being signed in September, which calls for a timeline for a U.S. troop pullout in exchange for the Taliban agreeing to cut ties with terrorist groups and entering into peace talks with their foes in the Afghan government.

If the agreement goes ahead, it would potentially bring an end to America’s longest war by launching direct peace talks between the Taliban and the Afghan government for the first time.

A deal would give President Donald Trump a talking point in his bid for re-election, allowing him to argue he fulfilled a campaign promise to extricate America from "endless" wars abroad.

But a previous attempt fell apart at the 11th hour in September, and it remained unclear if the Taliban was ready to negotiate a genuine peace settlement with a government in Kabul that it has long rejected as a "puppet" of the United States.

Since the U.S. and Taliban renewed discussions in the Qatari capital Doha at the end of last year, the talks have focused on a U.S. demand for the Taliban to scale back its attacks across the country as a test of its commitment to ending the conflict. In an earlier round of negotiations, the Taliban rejected the idea of a full-blown cease-fire, and as a result U.S. special envoy Zalmay Khalilzad has pursued a deal to "reduce" violence, though U.S. officials have yet to explain exactly what that would entail.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

U.S. special representative for Afghanistan, Zalmay Khalilzad, left, shakes hands with Afghanistan's Chief Executive Abdullah Abdullah in Kabul, Afghanistan Sept. 2, 2019. Afghan Chief Executive Office / Reuters

In the recent talks in Doha, Khalilzad — a veteran diplomat who once served as ambassador to Kabul — first proposed a wider reduction of violence deal that the Taliban rejected. The insurgents then came back with a more limited proposal, which the Americans viewed as inadequate but worth negotiating further, a former U.S. official told NBC News. In recent weeks, the two sides have found common ground around a compromise deal to reduce violence.

"It’s quite specific and detailed about what’s expected for each side," the former U.S. official said.

Afghan leaders struck an unusually upbeat tone in public statements Tuesday, signaling a breakthrough could be on the horizon.

Afghan President Ghani said on Twitter on Tuesday that Secretary Mike Pompeo informed him that "notable progress" had been made in the peace talks and spoke of a Taliban proposal to bring "a significant and enduring reduction in violence." Afghan Chief Executive Dr. Abdullah Abdullah also said Pompeo had expressed optimism about the discussions, saying "a reduction in violence and progress with current talks could lead to an agreement that would pave the way for intra-Afghan talks leading to durable peace."

The State Department declined to elaborate on the Afghan leader's comments but a spokesperson told NBC News the U.S. talks with the Taliban in Doha continue to focus on "the specifics of a reduction in violence."

The Pentagon declined to comment.

The war in Afghanistan is America's longest, having raged for 18 years and claimed the lives of around 2,300 troops, according to the Department of Defense.

From January 2009, when the United Nations began systematic documentation of civilian casualties, to September, some 34,000 civilians have been killed as a result of the armed conflict.

The U.S. has 12,000 to 13,000 troops in Afghanistan, but in December three current and former U.S. officials told NBC News that the Trump administration was poised to withdraw approximately 4,000 of them.

Talks broke down between the U.S. and Taliban in September as the two sides were nearing a deal. With a draft accord already hammered out, Trump at the last minute proposed inviting the Taliban and Afghan President Ghani to the Camp David presidential retreat to seal the deal. The Taliban refused the idea of flying to the U.S. unless the agreement was already announced. In a series of tweets, Trump said he called off the Camp David meetings because a U.S. soldier had been killed in a suicide bombing in Afghanistan.

But Trump authorized Khalilzad to revive discussions again following the Taliban’s release of Western hostages American Kevin King and Australian Timothy Weeks, and talks began in earnest in December. "The Taliban wants to make a deal, and we’re meeting with them," Trump said during an unannounced trip to Afghanistan in November.

The details of any "reduction in violence" or U.S. troop withdrawal are important only if the Taliban make good on a promise to begin direct talks with the Afghan government and other Afghan political figures, said Laurel Miller, a former senior U.S. official who took part in a previous attempt at peace negotiations during the Obama administration.

"That’s the real deal," said Miller, now with the International Crisis Group think tank. "All the rest of this is only window dressing if you don’t get to that."