In the past two years, there have been at least 13 attacks on the Shia community in Kabul alone.

Grieving families have gathered to bury their dead after the atrocity, but even amid the sombre atmosphere there was no respite from violence in the city.

Gunmen besieged a compound belonging to the Afghan intelligence service in a north-western Kabul area, opening fire as Afghan security forces moved in to cut them off.

Two gunmen who attacked the compound were killed by security forces after a six-hour siege.

A spokesman said police finally took control of a partially constructed building where the gunmen had holed up in order to shoot at the nearby compound.

The attacks, which come at the end of more than a week of assaults that have left scores of Afghan troops and civilians dead, show how militants are still able to stage large-scale attacks - even in the capital, Kabul - and undermine efforts by Afghan forces to provide security and stability on their own.

Afghanistan's IS affiliate is known as the Islamic State in Khorasan Province.

Khorasan is the ancient name for an area that encompassed parts of present-day Iran, Afghanistan and Central Asia.