In a post on Telegram, the Afghan branch of ISIS said the attack was in response to insults against the Prophet Mohammed — an apparent reference to remarks by officials of India's ruling party that have been condemned by many Muslim-majority countries.
The group said a suicide attacker stormed the temple on Saturday morning armed with a machine gun and hand grenades after killing its guard. It said other militants fought for more than three hours with Taliban fighters, who tried to intervene to protect the temple, attacking them with four explosive devices and a car bomb.
Taliban officials said one of their fighters and a Sikh worshipper were killed, while seven other people were injured.
The attack followed a visit last week by an Indian delegation to Kabul to discuss the distribution of humanitarian aid from India to Afghanistan.
Afghan and Indian media reports said the delegation discussed the possibility of reopening the Indian embassy, which was closed after the hardline Islamist militants seized power in August last year.
The number of bombings across Afghanistan has dropped since then, but several attacks — many of which have been against minority communities — have rocked the country in recent months, including several claimed by ISIS.
The UN's mission to Afghanistan called for protection for minorities in Afghanistan after Saturday's attack.
Indian Prime Minister Narendra Modi said on Twitter that he was "shocked" by the attack, while neighbouring Pakistan said it was "seriously concerned at the recent spate of terrorist attacks on places of worship in Afghanistan".
Sikhs are a tiny religious minority in largely Muslim Afghanistan, comprising about 300 families before the country fell to the Taliban. Many have since left, according to members of the community.
Most of those who remain are traders involved in selling herbal medicines and electronic goods brought from India.
In recent months, many impoverished Sikhs, including women and children, have taken refuge in the complex that was attacked on Saturday.
Sikhs in Afghanistan have been repeatedly attacked over the years. At least 25 people were killed in March 2020 when gunmen stormed another Sikh temple in Kabul in an attack that was also claimed by ISIS.