Police say the hours-long attack at a Shiite Muslim mosque in the Afghan capital Kabul has ended with all four attackers dead.
Police official Mohammed Sadique Muradi said two of the attackers blew themselves up and another two were shot by Afghan Security Forces.
Worshippers, wounded and dead were being evacuated from the mosque.
Initial reports said at least two people had died, including the cleric leading the service.
Meantime, a senior hospital official says at least 20 people were killed in the hours-long siege.
Mohammad Salim Rasouli, chief of Kabul's hospitals, said at least 50 more were wounded, many of them children, AP reported.
The mosque was packed with worshippers attending Friday prayers. Friday is the Muslim sabbath when worshippers usually attend prayers at the mosque.
Rasouli said the death toll could rise because many of the wounded were seriously hurt.
Afghan President Ashraf Ghani is condemning the attack on a Shiite mosque, calling on Islamic clerics around the world to condemn terrorism.
He said the extremists have turned to attacking houses of worship because they are being defeated on the battlefield.
He vowed that Afghanistan would stay united in the face of these attacks and that terrorism would be defeated.
The ISIL (also known as Daesh) group's affiliate in Afghanistan has claimed responsibility for an attack.
The ISIL-linked Aamaq news agency carried the claim on its website on Friday, while the attack in the Afghan capital was still developing.
In the claim, ISIL says two of its fighters carried out the assault. It did not give further details.
The attack was the latest by ISIL to hit the Afghan capital. Last month, the group attacked the Iraqi Embassy in Kabul and afterward, issued a warning to all Shiites in Afghanistan, saying ISIL militants would attack Shiite places of worship.
Within days of the embassy attack in Kabul, ISIL also took responsibility for a brutal suicide assault on a Shiite mosque in western Herat province that killed 32 people.