KABUL, Afghanistan — The number of people killed in an attack on a Shiite mosque in the Afghan capital during Friday prayers rose to at least 28 — up from 20 — including women and children, the chief of Kabul’s hospitals said Saturday. Meanwhile, hundreds took part in the burial of two dozen victims in the mosque compound.

Two assailants blew themselves up and another two were shot dead by Afghan security forces, according to police. Kabul hospital chief Mohammad Salim Rasouli said more than 50 people were wounded in the attack that went on for hours.

The Interior Ministry said four of the dead were police.

Hundreds of family members, relatives and local people participated in the burial of about two dozen victims inside the mosque compound Saturday.

Sayed Jan Agha, 34, lost his mother and an aunt in the attack. He said that he tried several times to get into the mosque and rescue his mother and other relatives, but security forces prevented him.

“My mother was martyred while she was trying to come down from the second floor, she was shot right at the stairs,” said Agha.

Agha said his aunt called him and asked for help while she was bleeding, but no one could help her while the battle was going on between the attackers and security forces and she died from her wounds, he said.

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 U.N. Assistance Mission in Afghanistan (UNAMA) in a statement condemned the attack. It said at least two attackers wearing police uniforms stormed the mosque while several hundred worshippers, including many women and children, attended Friday prayers. One assailant detonated his suicide vest outside the mosque, while another continued inside, indiscriminately killing and wounding people, the statement said.

“This latest in a series of attacks targeting members of the Shi’a community at worship has no possible justification,” said Toby Lanzer, the U.N. Secretary-General’s Deputy Special Representative for Afghanistan and acting head of UNAMA. “Such attacks directed against congregations and places of worship are serious violations of international law that may amount to war crimes.”

Terrified worshippers endured about four harrowing hours of gunfire and explosions before the four attackers were killed.

The Islamic State said in a statement that it had deployed two attackers to the mosque. There was no immediate explanation for the contradictory number of attackers.

Security forces surrounded the mosque in the northern Kabul neighborhood but did not initially enter to prevent further casualties to the many worshippers inside, police said. Later, as police tried to advance, one of the attackers set off an explosion that forced them to withdraw.

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 both the cavernous prayer hall for the men and the separate, second-floor prayer area for the women, he said.

The mosque could accommodate up to 1,000 people, Nasiri added.

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, Nasiri said.

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, IS also took responsibility for a suicide attack on a Shiite mosque in western Herat province that left 32 people dead.