KABUL, Afghanistan -- Gunmen stormed a Shiite mosque in the Afghan capital while worshippers were at Friday prayers, setting off an explosion that killed a security guard outside before pushing into the shrine.

More than 20 people were killed, including women and children, and at least 30 others wounded in the attack, according to Health Ministry spokesman Ismail Kawosi. A cleric who was leading the service was among the dead. Kawosi said the figures were still preliminary as police and soldiers were still assessing the scene after killing the four militants involved.

The Islamic State of Iraq and Syria (ISIS) claimed responsibility for Friday's attack in a statement posted online.

Get Breaking News Delivered to Your Inbox

The police were promptly deployed at the site in a northern Kabul neighborhood and encircled the mosque but waited before advancing inside in hopes of preventing further casualties, police official Mohammed Jamil said.

Afghan policemen try to comfort a man whose relatives were stuck at the site of a suicide attack followed by a clash between Afghan forces and insurgents after an attack on a Shi'ite Muslim mosque in Kabul, Afghanistan, Aug. 25, 2017. REUTERS

More explosions and gunfire echoed from the scene of the attack after the initial blast. The mosque had been packed with worshippers for Friday prayers, the high point of the Muslim week.

Mir Hussain Nasiri, a member of Afghanistan's Shiite clerical council, said the cleric who was performing the prayers was killed, but did not give his name. Nasiri said the gunmen took over the portion of the mosque with the separate prayer areas for men and women.

There have been several attacks against Shiite Muslim mosques in Afghanistan in recent weeks. Last month, 32 people were killed when gunmen stormed a Shiite mosque in western Herat province. ISIS claimed responsibility for that attack, also, and vowed to carry out more attacks against Afghanistan's minority Shiite Muslims, which the Sunni extremists consider to be heretics.

Meanwhile, in southern Kandahar province, Afghan security forces repulsed a Taliban attack on an outpost, according to provincial police chief's spokesman, Zia Durrani. Four members of the security forces died in the exchange and another seven were wounded, he said.

Durrani said the attack occurred overnight and the Taliban sustained heavy casualties. There was no immediate comment from the Taliban.

Elsewhere, provincial deputy police chief Nisar Ahmad Abdul Rahimzai saids that Afghan security forces recaptured a district in eastern Paktia province from the insurgents.

The summer fighting season in Afghanistan has been brutal so far this year, with relentless Taliban attacks around the country as the insurgents battle to expand their footprint.