DOHA, Qatar — After nearly 20 years of conflict, the Afghan government came face to face with Taliban leaders beneath ornate chandeliers in a grand ballroom Saturday to begin what many expect will be intensely difficult negotiations to shape Afghanistan's future.

At the opening ceremony launching direct, formal peace talks, Afghan government officials were seated across from Taliban officials led by the group’s top political figure, Mullah Abdul Ghani Baradar, with Secretary of State Mike Pompeo and Qatari and other U.S. officials between the two sides.

Pompeo described the moment as “a truly momentous occasion” but cautioned that the way forward would “require hard work and sacrifice.”

Baradar also acknowledged the potential for challenges ahead, but his brief remarks were largely sanguine, calling for an Afghanistan “where everyone lives in peace and harmony and no one feels any discrimination.”

After the ceremony Saturday, Taliban leaders and the Afghan government sat down for official peace talks for the first time, although discussions were limited to ironing out logistics and agreeing to a second meeting as early as Sunday.

The Taliban held power over most of Afghanistan from 1996 to 2001, when the group, then closely aligned with al-Qaeda, was ousted by U.S.-backed Afghan forces in the weeks after the Sept. 11 attacks on the United States. In the prolonged conflict that followed, which has killed tens of thousands of civilians and more than 2,440 U.S. troops, Taliban militants have reestablished control or influence over roughly half of Afghanistan.

That influence extends to the negotiating table, where Taliban militants won concessions in talks with the United States that culminated in a peace deal signed in February. After showing resilience on the battlefield and stubbornness in negotiations, the militants enter the landmark talks with many of their demands met in the U.S. deal and with leverage gained from relentless attacks on Afghan forces.

That leverage could prove advantageous as the two sides seek to merge their dramatically different visions of a postwar Afghanistan.

Abdullah Abdullah, the head of the Afghan government delegation, told reporters on the flight from Kabul to Doha on Friday that the talks are “a great opportunity” despite the differences between the two sides. But he warned that it would be a miscalculation “if one side thinks they have the upper hand.”

Any resolution will demand significant compromises from one or both sides. The Taliban has long been opposed to democratic elections, and its leaders have issued only vague statements on the group’s position on women’s rights. Delegates from the Afghan government side support keeping the country’s constitution intact and preserving advances in civil liberties.

The launch of negotiations was plagued by months of delays as the Afghan government pushed back against the conditions set for the talks by the earlier U.S.-Taliban deal. That agreement charts a course for the full withdrawal of American troops, a central Taliban objective, but does not in exchange explicitly demand a reduction in violence — a key government request.

The deal also called for the release of thousands of Taliban prisoners ahead of direct talks, an issue so fraught that the final six high-value Taliban prisoners were transferred from Afghan custody just two days before the talks, over strong objections from key American allies France and Australia.

Taliban leaders celebrated the deal as a victory, breaking out into chants of “God is great” at the signing ceremony. But many Afghan officials and civilians viewed the document as a betrayal. It contained no language ensuring Afghanistan would remain a democracy, made no mention of women’s rights or civil liberties, and called for the prisoner release before talks began, a move some viewed as ceding key government leverage.

Zalmay Khalilzad, the U.S. special envoy for Afghanistan, acknowledged that the Afghan government thinks the deal could have been negotiated differently to put Afghan leaders in a stronger position. One long-held desire of the Afghan government was to negotiate with the Taliban directly.

“But we tried that for God knows how many years,” Khalilzad said in an interview Friday. He defended the approach that he spearheaded to negotiate with the Taliban first and then “open the door” to peace negotiations between the government and the militants.

“There is now an opportunity to reach an end to the war,” he said.

Afghan and former U.S. officials say that such an opportunity might have existed earlier in the conflict but that years of missteps and squandered opportunities allowed the repressive militant group to thrive.

Nearly 19 years ago, the Taliban was all but defeated as a military organization. Scattered by an intense U.S. bombing campaign, low- and mid-level fighters abandoned their posts, melting into the population, and the group’s senior leadership fell back across the border into Pakistan.

A former senior U.S. military commander previously stationed in Afghanistan said that in the years after the U.S. invasion, he had the impression that “everything was possible.”

“I’d visit these bases that didn’t have a single strand of concertina [razor] wire around them. And we were out in these remote areas,” he said. The former commander spoke on the condition of anonymity to discuss ongoing U.S. diplomatic efforts.

“It was a period of opportunity,” he said.

But that was before the Taliban regrouped.

By 2005, the Taliban was carrying out devastating attacks on U.S.-led coalition forces and the Afghan military. And in the years that followed, despite surges in the number of U.S. and coalition troops deployed to Afghanistan, the militants continued to demonstrate remarkable resilience, keeping up their recruiting despite suffering heavy losses.

Ashley Jackson, an expert on the Taliban with the Overseas Development Institute, attributes the Taliban’s military successes to its ability to “shape shift,” adjusting to changes in U.S. military tactics and “the fact that they are able to come back from the dead so many times.”

A senior Taliban commander in eastern Afghanistan said he remembered how the initial heavy waves of American airstrikes ripped through the ranks of his fighters. But he said he never feared for the future of his movement.

“Our leaders told us the enemies will come, and they will destroy some of us, but they will not destroy all of us,” he said, speaking on the condition of anonymity because he was not authorized to talk to the media.

Over the course of the war that would define his adult life, the commander said he saw a direct correlation between increased violence by the United States and its allies and increased support for his movement. As the United States ramped up the war against the Taliban with heavier use of airstrikes and more-frequent night raids in 2009, men from his town and neighboring villages began to approach him, asking how they could help the Taliban.

“The basic thing was the cruelty of the Americans and the cruelty of the Afghan government toward civilians,” he said. “American airstrikes killed civilians, and American troops brutalized them in other ways, and it was because of this that people began supporting us.”

U.S. officials have said that they use procedures to try to avoid civilian casualties when conducting airstrikes.

“We always knew that we would win either militarily or they could come to us asking for peace,” the senior Taliban commander said.

The United States first approached Taliban leaders about peace talks in 2011, under President Barack Obama, to negotiate the withdrawal of U.S. troops from the country. Since then, talks began and collapsed several times. Coalition troop numbers have surged and waned. But public rhetoric that the U.S.-led coalition could not win the war emboldened the Taliban.

Under President Trump, who campaigned on bringing all U.S. troops home from Afghanistan, Khalilzad was appointed special representative to lead the peace effort and was granted unprecedented autonomy. He abandoned an approach used during the Obama administration that certain conditions, such as requiring the Taliban to pledge to respect the Afghan constitution, be met before talks, and he rarely briefs Congress.

A deal appeared within reach a year ago as rumors swirled about a potential gathering of all the parties. Then Trump abruptly scuttled talks, announcing on Twitter that he had canceled a planned summit of U.S., Afghan and Taliban leaders at Camp David in September 2019 because an American had been killed in Afghanistan.

All told, Khalilzad worked for over a year to reach the deal signed in February. “One shouldn’t underestimate them as negotiators, in my judgment,” Khalilzad said of the Taliban. “Their advantage, in my view, is they are united.”

Taliban demands have remained steady. During the first meetings with U.S. officials nearly 10 years ago, the group was narrowly focused on prisoner releases, the withdrawal of all U.S. forces and gaining a substantial role in the Afghan government.

Asked what advice he would give Afghan negotiators preparing for the first round of talks this week, Khalilzad said, “They should take [the Taliban] seriously.”

Rustam Shah Mohmand, a former Pakistani ambassador to Afghanistan, described the Taliban’s negotiating style more bluntly: “They’re very stubborn but also clever.”

Aziz Tassal in Kabul and Haq Nawaz Khan in Peshawar, Pakistan, contributed to this report.