Ministry of Interior spokesperson Najib Danish said at least three policemen were killed and eight wounded.
It's at least the second time this month that ISIS has claimed responsibility for an attack targeting Shiite worshippers in Afghanistan. The bombings took place soon before Friday prayers at the mosque.
Security forces exchanged fire with the assailants and sound of an explosion was heard almost two hours after the attack began.
He said the extremists have turned to attacking houses of worship because they are being defeated on the battlefield.
Officials said two blew themselves up and another two were shot by Afghan security forces.
Buckingham Palace on lockdown after attack on police officers
The attack happened just one hour after a man was shot in the centre of Brussels after attacking two soldiers with a "machete" . The palace's most famous resident, Queen Elizabeth II, is now staying at another of her properties, in Scotland.
IS has claimed responsibility for a series of attacks killing dozens of Shiites in Kabul over the past year, including twin explosions in July 2016 that ripped through crowds of Shiite Hazaras, killing at least 85 people and wounding more than 400. "Half of the mosque was full of worshipers - women upstairs and men downstairs, hundreds of men and women", he said, pacing barefoot.
Witnesses told Reuters gunmen threw grenades and then entered the mosque. That attack killed more than 30 people as they gathered for evening prayers, according to local officials.
Provincial police chief's spokesman, Zia Durrani, says the security forces repulsed the Taliban attack with the help of air support from the Afghan air force.
"Two Afghan police forces were martyred and two others were wounded and have been taken to hospital".