Militants stormed a packed Shiite mosque in the Afghan capital during Friday prayers in an attack that lasted for hours and ended with at least 20 worshipers killed and 50 others, many of them children, seriously wounded, an official said.
Two of the assailants blew themselves up and another two were shot to death by Afghan security forces, according to police official Mohammed Sadique Muradi.
The Islamic State group claimed responsibility for the attack, the latest to target Afghanistan's minority Shiites. The Taliban condemned the violence, with a spokesman for the militants, Zabihullah Mujahid, telling the Associated Press in a telephone interview that the group had nothing to do with it.
President Ashraf Ghani condemned the violence and said the militants were turning to attacking places of worship because they were losing on the battlefield. He urged Islamic clerics everywhere to condemn the bloodshed.
The death toll of 20 was expected to rise because many of the victims were seriously wounded, said Mohammad Salim Rasouli, chief of Kabul's hospitals.
Terrified worshipers endured about four harrowing hours of gunfire and explosions during the afternoon before the four attackers were killed.
Islamic State said in a statement on the website of its Aamaq news agency that it had deployed two attackers to the mosque. There was no immediate explanation for the contradictory number of attackers.
Security forces had surrounded the mosque in the northern Kabul neighborhood but did not initially enter to prevent further casualties to the many worshipers inside, police official Mohammed Jamil said. Later, as police tried to advance, one of the attackers set off an explosion that forced them to withdraw, Muradi said.
The cleric who was performing the prayers was among the dead, said Mir Hussain Nasiri, a member of Afghanistan's Shiite clerical council. The gunmen had taken over the cavernous prayer hall for men and the separate, second-floor prayer area for women, he said.
The mosque could accommodate up to 1,000 people, Nasir said.
When police initially tried to get inside, they discovered the militants had blocked the door leading to the second floor, turning the women upstairs into hostages, he said.
"I was trying to escape over the wall when I saw my daughter, who was wounded, also trying to climb the wall," one man who gave his name only as Bismillah told the AP.
"There was another girl who was shot in the head. I saw the body myself," he said. "Finally I managed to escape with my daughter and the police escorted us to safety from the back of the mosque."
Last month, the Sunni-dominated Islamic State group attacked the Iraqi Embassy in Kabul and then warned Shiites in Afghanistan that their mosques would be targeted. Sunni extremists consider Shiites to be heretics.
Within days of that, Islamic State also took responsibility for a suicide attack on a Shiite mosque in western Herat province that left 32 people dead.
In southern Kandahar province Friday, Afghan security forces repulsed a Taliban attack on an outpost overnight, according to the provincial police chief's spokesman, Zia Durrani. Four members of the security forces died in the exchange and seven others were wounded, he said.
Durrani said the Taliban sustained heavy casualties. There was no immediate comment from the militants.
Elsewhere, provincial deputy police chief Nisar Ahmad Abdul Rahimzai said Afghan security forces recaptured a district in eastern Paktia province from the insurgents.
The summer fighting season in Afghanistan has seen relentless Taliban attacks as the insurgents battle to expand their footprint.
On Thursday, Gen. John Nicholson, the top U.S. general in Afghanistan, and Hugo Llorens, the U.S. Embassy's special chargé d'affaires, told reporters in Kabul that the new U.S. strategy was a promise to Afghans that together they would defeat terrorism and prevent terrorist groups from establishing havens.
Nicholson vowed to defeat the country's Islamic State affiliate and the remnants of Al Qaeda, and he had the following message to the Taliban: "Stop fighting against your countrymen. Stop killing innocent civilians. Stop bringing hardship and misery to the Afghan people. Lay down your arms and join Afghan society. Help build a better future for this country and your own children."
President Trump had announced the new plans for Afghanistan on Monday. Though he did not give specifics, senior U.S. officials have said that he might send up to 3,900 more troops, with some deployments beginning almost immediately.
11:15 a.m.: This article was updated with additional details and comments from Gen. John Nicholson.
7:15 a.m.: This article was updated with a revised death toll.