WASHINGTON -- America's longest war may finally be nearing an end.

The United States and the Islamists it toppled from power in Afghanistan are poised to sign a peace deal Saturday after a conflict that outlasted two U.S. commanders in chief and is now led by a third eager to fulfil a campaign promise to extricate America from "endless wars."

More than 18 years since President George W. Bush ordered bombing in response to the Sept. 11, 2001, attacks, the agreement will set the stage for the withdrawal of U.S. troops, some of whom were not yet born when the World Trade Center collapsed on that crisp, sunny morning that changed how Americans see the world.

Saturday's ceremony also signals the potential end of a tremendous investment of blood and treasure. The U.S. spent more than $750 billion, and on all sides the war cost tens of thousands of lives lost, permanently scarred and indelibly interrupted. Yet it's also a conflict that is frequently ignored by U.S. politicians and the American public.

In the Qatari capital of Doha, America's top diplomat will stand with leaders of the Taliban, Afghanistan's former rulers who harboured Osama bin Laden and his al-Qaida network as they plotted, and then celebrated, the hijackings of three airliners that were crashed into lower Manhattan, the Pentagon and a field in western Pennsylvania, killing almost 3,000 people.

It will likely be an uncomfortable appearance for Secretary of State Mike Pompeo, who privately told a conference of U.S. ambassadors at the State Department this week that he was going only because President Donald Trump had insisted on his participation, according to two people present.

A statement from Trump on Friday said Pompeo will "witness" the signing of the agreement, leaving unclear if he will personally sign it on behalf of the United States, or if he will shake hands with Taliban representatives.

U.S. troops are to be withdrawn to 8,600 from about 13,000 in the weeks following Saturday's signing. Further drawdowns are to depend on the Taliban meeting certain counter-terrorism conditions, compliance that will be assessed by the United States. But officials say soldiers will be coming home.

Trump, as he seeks re-election this year, is looking to make good on his campaign promise to bring troops home from the Middle East. Still, he has approached the Taliban agreement cautiously, steering clear of the crowing surrounding other major foreign policy actions, such as his talks with North Korea.

Last September, on short notice, he called off what was to be a signing ceremony with the Taliban at Camp David after a series of new Taliban attacks. But he has since been supportive of the talks led by his special envoy, Zalmay Khalilzad.

In a statement released by the White House, Trump said Friday that if the Taliban and Afghan governments live up to the commitments in the agreement, "we will have a powerful path forward to end the war in Afghanistan and bring our troops home,"

"These commitments represent an important step to a lasting peace in a new Afghanistan, free from al-Qaida, ISIS and any other terrorist group that would seek to bring us harm," Trump said.

Under the agreement, the Taliban promise not to let extremists use the country as a staging ground for attacking the U.S. or its allies. But U.S. officials are loath to trust the Taliban to fulfil their obligations.

Pompeo did not mention the Afghan agreement as he touted Trump administration foreign policy achievements in a speech to a conservative group Friday. He has expressed doubts about the prospects. Yet, he will give his imprimatur to an agreement which he also has said represents "a historic opportunity for peace" after years and pain and suffering.

"We are now on the cusp of having an opportunity which may not succeed, but an opportunity for the first time to let the Afghan peoples' voices be heard," he told reporters this week.

If the agreement is successful, Afghanistan, the "graveyard of empires" that has repeatedly repelled foreign invaders from imperial Britain and Russia to the Soviet Union, will have once again successfully turned away a world power from its landlocked borders.

But prospects for Afghanistan's future are uncertain. The agreement sets the stage for peace talks involving Afghani factions, which are likely to be complicated. Under the agreement, 5,000 Taliban are to be released from Afghan-run jails, but it's not known if the Afghan government will do that. There are also questions about whether Taliban fighters loyal to various warlords will be willing to disarm.

It's not clear what will become of gains made in women's rights since the toppling of the Taliban, which had repressed women and girls under a strict brand of Sharia law. Women's rights in Afghanistan had been a top concern of both the Bush and Obama administration.

In a sign of "the international community's commitment to Afghanistan," a separate ceremony will be held Saturday in the Afghan capital of Kabul, with U.S. Defence Secretary Mark Esper and NATO Secretary-General Jens Stoltenberg, said Sediq Sediqqui, spokesman for Afghanistan's President Ashraf Ghani.

Already, some U.S. lawmakers and veterans of the conflict have raised red flags about any agreement with the Taliban.

Rep. Liz Cheney of Wyoming led 21 Republican legislators in demanding that the administration not concede anything to the Taliban that would allow them to once again harbour those who seek to harm U.S. citizens and interests. Cheney, the daughter of former President Bush's vice-president, Dick Cheney, urged Pompeo and Esper in a letter to reject any commitment to a full withdrawal of American troops.

Pompeo said, "We're proud of our gains, but our generals have determined that this war is unlikely to be won militarily without tremendous additional resources. All sides are tired of fighting."

On this, he is in rare agreement with Sen. Elizabeth Warren of Massachusetts, who said this week in a Democratic presidential debate that the government has "a sacred responsibility to" American soldiers. "That is not to use our military to solve problems that cannot be solved militarily. We are not winning in Afghanistan. We are not winning in the Middle East," she said.