The group’s propaganda agency, Amaq, released a statement shortly after the attack saying its fighters were behind the killings.
Gunmen stormed the Shia mosque, attacking worshippers gathered for Friday prayers.
A cleric who was leading the service was among those killed, police said.
The Amaq statement referred to an “inghimasi” attack, where assailants use weapons to inflict the maximum number of casualties, only detonating their suicide vests when they have run out of ammunition.
As the attack unfolded, police encircled the mosque but initially avoided advancing inside to prevent further casualties, police official Mohammed Jamil said.
Later, officers attempted to enter the mosque but withdrew after one of the attackers set off an explosion.
By Friday evening police said they had secured the mosque, and all three attackers were dead.
Witnesses said the assailants threw grenades, and police officials said a suicide bomber had detonated himself at the gate, Reuters reported.
A second suicide bomber detonated among a group of women in the mosque, an official said.
Security sources put the overall toll at 30 people killed and “dozens” wounded.
Mir Hussain Nasiri, a member of Afghanistan’s Shia clerical council, said the gunmen had taken over the portion of the mosque with separate prayer areas for men and women.
He said the mosque could accommodate up to 1,000 people. Access to the second floor, where the women pray, was blocked by attackers. He said that meant they gunmen were holding women who were there as hostages.
Source: The Independent