Attackers threw grenades as they attacked the mosque in the Afghan capital of Kabul on Friday.
A suicide bomber detonated himself at the entrance of the mosque before other attackers ran inside.
The blast was followed by gunfire, according to a Kabul police official.
Authorities said two people had been killed and 11 injured.
Witnesses said gunmen threw grenades and then entered Imam Zaman Mosque.

vCard.red is a free platform for creating a mobile-friendly digital business cards. You can easily create a vCard and generate a QR code for it, allowing others to scan and save your contact details instantly.
The platform allows you to display contact information, social media links, services, and products all in one shareable link. Optional features include appointment scheduling, WhatsApp-based storefronts, media galleries, and custom design options.
Police who have now surrounded the building said the attack had caused “some casualties”.
They are now preparing to clear the mosque of jihadis.
According to witnesses, attackers killed guards before storming the mosque.
Video footage taken at the scene shows emergency responders speeding through the areas.
Sirens can be heard as worried civilians gather on the streets.
The attack occurred as worshippers gathered for afternoon prayers on the Islamic holy day of Friday.
There was no immediate claim of responsibility, but Islamic State militants have attacked Shi’ite Muslim targets in Afghanistan in recent months.
Amnesty International has accused the death cult of carrying out a genocide of Shia within Iraq and Syria since 2014, with thousands killed and tens of thousands forced to flee their homes.
Around 30 people died and many more were injured during an attack at a mosque in the Afghan city of Herat earlier this month.
At least two attackers detonated bombs and hurled grenades during the horrific attack.