Want smart analysis of the most important news in your inbox every weekday, along with other global reads, interesting ideas and opinions? Sign up for the Today’s WorldView newsletter.

On Saturday evening, a man detonated a bomb in a crowded wedding hall in Kabul. The unprecedented suicide attack on a civilian gathering packed with women and children appeared designed to cause as much death and suffering as possible.

Witnesses say that at least 1,000 guests were gathered in the salon in the Dubai City wedding hall — a lively feature of the Afghan capital that can bustle with celebrations on a weekend night — at 11 p.m. when the bomb went off. “It was like doomsday,” wedding guest Sakhi Mohammed told The Washington Post. The Afghan Interior Ministry said at least 63 people died and more than 180 people were wounded.

Saturday’s attack marks one of the worst assaults on Afghan civilians in years of conflict, and it comes at a perilous time for the country: The United States is in the midst of peace talks with the Taliban, a Sunni Islamist fundamentalist group that proclaimed a totalitarian Islamic emirate in Afghanistan in 1996 and has been fighting a brutal insurgency since being forced from power after the U.S.-led invasion of the country in 2001.

Any deal with the Taliban could be the first step to finally ending an American military mission in Afghanistan that has dragged on for almost two decades. But there are deep suspicions about the Taliban’s commitment to peace, and some initially suspected it was behind Saturday’s attack.

On Sunday, a local affiliate of the Islamic State, a group that is sometimes a rival to the Taliban and is not party to the talks with the United States, asserted responsibility for the bombing. Zalmay Khalilzad, a veteran diplomat who is the U.S. envoy for peace talks, said the attack showed why a peace deal with the Taliban is so vital.

Khalilzad has a point: A deal with the Taliban may enable the Afghan government to better combat the threat posed by the Islamic State in Afghanistan.

And yet at the same time, the attack signaled just how difficult it may be to achieve lasting peace in a country as divided and scarred as Afghanistan.

Though the Taliban condemned Saturday’s attack as a “brutal act,” it has also conducted suicide attacks that targeted civilians in Kabul. In recent months, a car bomb that killed 45 people and injured 145 and a bomb and gun attack on a political party’s office that left 20 dead and more than 50 injured have been attributed to the Taliban.

However, while they both claim extremely conservative Sunni Muslim beliefs, the Taliban and the Islamic State have distinct ideologies and tactics. The Taliban is domestically focused on Afghanistan and generally focused on military targets. The Islamic State is an internationally oriented group for whom brutal attacks on civilians are a core part of its strategy.

The Islamic State’s self-proclaimed caliphate in Syria and Iraq crumbled after a military campaign by the United States and its allies, but it remains far from defeated. With tens of thousands of former fighters and their families in various internally displaced people (IDP) camps in the Levant, some say the caliphate is on the brink of re-forming there.

Just as worryingly, the group’s Afghanistan affiliate has surged in recent months. Though it was originally just a handful of fighters from Afghanistan and Pakistan, experts now believe it has thousands of fighters from an array of countries. A U.S. intelligence official based in Afghanistan told the Associated Press this summer that the Islamic State in Khorasan could ultimately pose a threat not just to Afghans, but to United States and Europe, too.

Threatened with an Islamic State resurgence, some U.S. officials have suggested the Taliban could become an ally in the military fight against the group’s Afghan affiliate. But Afghan President Ashraf Ghani said Sunday that the Taliban ultimately bears part of the blame for attacks that target civilians, because it provides a “platform for terrorists.”

The Taliban refuses to talk to Ghani, who it claims is a U.S. puppet. Though intra-Afghan talks are expected to begin after an agreement is reached between the United States and the Taliban, the secrecy shrouding those talks has prompted a suspicion among many in the country: Does the United States just want out of Afghanistan at all costs?

President Trump has long spoken of his desire to get U.S. troops out of Afghanistan; last December, he had to be talked out of abruptly pulling half of the U.S. forces there out of the country. Critics say this has undermined Khalilzad’s leverage in talks with the Taliban, but Trump has said he expects a total pullout of troops by 2020 to be politically expedient, according to Secretary of State Mike Pompeo.

Under the current talks, an initial withdrawal of roughly 5,000 of the 14,000 U.S. troops in Afghanistan would be made in return for the Taliban renouncing the extremist group al-Qaeda and stopping it from working in Taliban-held areas. That move could allow the United States to claim a partial victory in a war that began after the 9/11 terrorist attacks coordinated by al-Qaeda’s Osama bin Laden.

But such a deal may ultimately do little to improve the lives of average Afghan civilians if the Taliban reneges after the United States leaves. “The Taliban is fighting to resurrect its totalitarian Islamic Emirate of Afghanistan and has already established a shadow government throughout parts of the country,” Thomas Joscelyn and Bill Roggio of the Foundation for Defense of Democracies (FDD) warned in March.

Even if the deal with the Taliban goes as planned, it is not clear that all Taliban commanders would abide by the terms agreed to by their leadership: Some may choose to join the Islamic State, as others have done in the past.

Trump may be keen to wash his hands of Afghanistan — his flippant suggestion last month that he could win the war there but would have to kill 10 million people drew an angry response from the country. But for those actually affected by the violence in Afghanistan, there is no washing it away.

“I lost my brother, my friends, my relatives,” the groom at Saturday’s bombing, Mirwais Elmi, told local TV on Sunday. “I never thought such a thing would happen at my wedding. I will never see happiness in my life again.”

Want smart analysis of the most important news in your inbox every weekday, along with other global reads, interesting ideas and opinions? Sign up for the Today’s WorldView newsletter.