The Islamic State said in a statement on the website of its Aamaq news agency that it had deployed two attackers to the mosque.
Kabul: 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.
Mohammad Salim Rasouli said more than 50 others were wounded in the attack a day earlier that went on for hours.
Two 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.
Terrified worshippers endured about four harrowing hours of gunfire and explosions during the afternoon before the four attackers were killed.
The 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 worshippers 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 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, Nasir 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, Nasir 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.