The attack came on the holy night on Laylat al-Qadr, the night of power, commemorated on the 19th, 21st and 23rd days of Ramzan.
"Terrorist attack on Al Zahra mosque in west of Kabul. Special forces have been sent to the area," interior ministry spokesman Najib Danish said on Twitter.
The Interior Ministry says casualties would have been much higher had the guards not engaged the attackers at the gate of the mosque.
A prominent trader, Haji Ramaza, who also contributed to the building of the mosque has been killed.
The ISIS terror group has claimed the responsibility for the attack. The group has targeted minority Shia Hazaras in Afghanistan before. In November 2016, the group claimed an attack on a Kabul mosque that killed 30 people and wounded over 80.