DOHA, Qatar—The United States and the Taliban agreed on a peace deal Saturday that calls for swift reductions in U.S. forces in Afghanistan in return for commitments by the militant group to reject foreign terrorists, a major step toward ending America's longest war.

To shouts of "God is great," the accord was signed by U.S. and Taliban negotiators side by side in a luxury hotel ballroom in a scene once all but unthinkable. The sides agreed that the U.S. will cut its troop levels from around 12,000 today to 8,600 by early summer—and eventually to withdraw completely from Afghanistan if al-Qaeda and other terror groups do not reemerge there.

Dozens of turbaned, bearded Taliban - some with smart phones, others fingering worry beads - took seats in the red-carpeted hall for the signing, many of them sitting in proximity to current and former U.S. officials, their longtime foes, for the first time.

"Agreement for Bringing Peace to Afghanistan," read a sign in English, Arabic and Pashto on the dais where the officials inked the deal.

The agreement offers perhaps the best opportunity yet for the U.S. to extricate itself from a grinding 19-year war that has cost the lives of more than 2,400 U.S. soldiers and hundreds of thousands of Afghans since it invaded after the terror attacks on Sept. 11, 2001 and ousted the Taliban from power.

The agreement does not involve a full end to the U.S. military presence in Afghanistan: The initial withdrawals would only return troop numbers to about the same level achieved by former President Barack Obama, who oversaw a steep pullout from Afghanistan that Trump reversed a few months after he took office.

But even a partial pullout would give Trump a signature election-year achievement, enabling him to claim he has followed through on his pledge to scale back overseas wars, a goal that has largely eluded him in Iraq and Syria.

In the four-page pact, the U.S. pledged to remove all forces from Afghanistan within 14 months and to begin "immediate" work on freeing some 5,000 Taliban prisoners. It stated that the Taliban "will send a clear message" that Al Qaeda and "those who pose a threat to the security of the United States and its allies have no place in Afghanistan."

"The agreement we sign today will be the true test," Secretary of State Michael R. Pompeo said as he opened the ceremony.

The deal was finalized after a week-long pause in fighting that saw attacks across Afghanistan drop sharply.

It commits the Taliban to an eventual ceasefire and to launch talks for the first time with U.S-backed government in Kabul on a political settlement of the conflict—demands the militant group has steadfastly rejected in the past.

But Taliban negotiators set aside those objections in return for a pledge by the U.S. to withdraw its troops, the group's longtime goal and one that meshed with Trump's own desire to bring troops home in the middle of an election year.

Afghan officials in Kabul reacted cautiously to the agreement.

"The reduction of violence was a good start. I hope it will come to a ceasefire," Defense Minister Asadullah Khalid said.

"But the Afghan National Army has a duty, a job. Even with a peace agreement, they will continue to control and keep their positions, however in a defensive way."

The Kabul government only grudgingly agreed to begin power-sharing talks with the Taliban after U.S. envoy Zalmay Khalilzad opened direct talks with the Taliban for the first time last year. That raised fears of President Ashraf Ghani and other officials in Kabul that the U.S. was willing to reach a separate peace with their longtime foes.

Though Pompeo attended the ceremony, the agreement was signed by Khalilzad, who was born in that country and later emigrated to the United States, and by Mullah Abdul Ghani Baradar, the Taliban's top political leader and a longtime advocate of negotiations.

Taliban leaders staged what amounted to a brief victory parade on Doha streets before the signing ceremony, likening the deal to previous victories over other foreign armies who sought to occupy Afghanistan, including the British and the Soviets,

"This historic day in our history is a day of pride. Today is the day that our fathers celebrated 30 years and a hundred years ago by defeating Britains and Russians," said Mohammed Abas Stanekzai, a senior Taliban negotiator, as other Taliban waved the group's flag and cheered.

A video of the march was posted on YouTube.

"After 20 years of jihad are celebrating a day that Islamic Emirate would sign the agreement with the invader Americans which is about withdrawal of their troops and the victory of Afghanistan Mujahedeen," he added, while also warning Taliban "not to become too arrogant."

He said the "American invaders" will be gone in 14 months.

"Our brother and our elder Mullah Baradar will sign this agreement with the American invaders," Stanekzai said. "Based on this agreement foreign troops would leave Afghanistan within 14 months and Afghanistan would be independent once again."

In reaching a deal with the Taliban, a coalition of largely ethnic Pashtun militia groups who imposed a harsh form of Islam on the country and allowed Osama bin Laden and other terror leaders to operate from their territory, Trump has at least on paper achieved the makings of a potential ending of the conflict.

But the deal is fraught with risks and unknowns that could easily cause it to collapse, former U.S. officials and analysts say.

The looming departure of the U.S. could reignite a four-decade-old civil war, a conflict that predated the U.S. invasion and that could quickly intensify again, as warlords and rival ethnic groups rearm and resume the bloody fighting that over four decades left the country one of the poorest in the world.

If violence does spike, Trump or his successor will have to decide whether to proceed with the planned pullout or halt it in hopes of preventing Afghanistan from once again descending into chaos.

"There is a risk that it will very quickly breakdown," said Laurel Miller, a former State Department special representative for Afghanistan. "If the U.S. loses interest, it's hard to see where the glue for this process comes from."

The timing of the the next round of talks, which are scheduled to begin March 10 in Oslo, could hardly be worse for Ghani, the Afghan president, who this month was declared the winner of presidential elections— nearly five months after the vote. His chief rival, Abdullah Abdullah, has refused to recognize that outcome and declared himself the victor.

The standoff has delayed appointment of a negotiating team for the talks with Taliban.

The two sides appears far apart, with Ghani and his advisors seemingly intent on deal that allows the Taliban to join the government, while Taliban negotiators appear to have in mind more far-reaching overhaul that give them a major voice in running the country.

Having succeeded in forcing the U.S. to agree to a withdrawal after two decades of fighting, Taliban leaders consider themselves to be operating from a position of strength, Paul Miller, a former U.S. National Security Council official who oversaw Afghanistan policy said in remarks last week at the Center for National Security, a centrist Washington think tank.

Many Taliban were forced to flee to Pakistan early in the war. Its leaders took refuge in the remote city of Quetta while others used its largely ungoverned tribal areas to mount attacks inside Afghanistan, fighting on year after year, despite often severe casualties in battles with the U.S. and Afghan troops.

Though its support in Kabul and other Afghan cities is low, the Taliban has steadily gained ground in rural areas in recent years, taking back control of districts in the south and east of the country that had been under under Kabul's control a decade ago when the U.S. had nearly 100,000 troops in the country.

Attacks by the Taliban and other militant groups "increased considerably in late 2019," according to data provided by the U.S. military to the Special Inspector General for Afghanistan Reconstruction in a report released in January. In response,

the U.S. stepped up airstrikes, dropping more bombs in 2019 than in any year in over a decade.

Without continuing U.S. pressure on the Taliban, its leaders could quickly back away from the agreement or the Afghan government could become mired its own internal divisions, analysts said.

There are also growing fears especially among Afghanistan's urban population that the Taliban militants could reclaim power in some areas of the country and take away women's rights and other hard-won freedoms as they seek to reimpose their harsh form of Islamic law.

U.S. officials said they will have a seat at the talks in Oslo and will press for protecting women's and minority rights, as well as for the survival of the Afghan government, which remains wracked by corruption and unable to fully control large parts of the country.

"A high priority for us is absolutely the protection of women's rights," a senior State Department official told reporters in Washington. "We will use our voice."

But keeping the talks on track will require the U.S. to use the leverage it still has over the Taliban to force them to a deal. That leverage includes threatening to withhold international aid, on which Afghanistan is heavily dependent, analysts said.

U.S. officials also insist that the timetable for reducing troop levels below 8,600 will dependent on conditions in the country—specifically the Taliban's adherence to its promise not to allow al Qaeda and other terror groups to reestablish a presence on Afghan territory.

Both sides are likely to continue to limit attacks in hopes of a cease fire will take hold in coming weeks. The U.S. and its allies are planning training and better equipping Afghan army and police while the talks are under way. And the U.S. military says it will continue to carry out counter-terrorism operations against Islamic State, which has fighters in eastern parts of the country.

The U.S. could also delay additional withdrawals if the Oslo talks collapse or the Taliban refuses to negotiate in good faith, though it's unclear whether Trump would decide to halt the pullout in that case.

"If the talks fail there is nothing in the agreement that obliges the United States to withdraw its troops," said the official, who briefed reporters on the condition of not being named. "That's not to say that president doesn't have prerogatives as commander-in-chief to make any decision he feels is appropriate."

This article is written by David S. Cloud, Tracy Wilkinson from The Los Angeles Times and was legally licensed via the Tribune Content Agency through the NewsCred publisher network. Please direct all licensing questions to legal@newscred.com.