Within hours, Daesh (ISIL or ISIS) claimed responsibility for the attack. Those killed included a child whose body was brought to a Kabul hospital, the emergency services and the hospital said. At least seven people were wounded.
Afghanistan's Interior Ministry said police responded promptly to the attack on the Sikh place of worship, known as a Gudwara, as shooting was still underway.
The lawmaker, Narindra Singh Khalsa, said he rushed over to help after receiving a call from a worshiper inside the Gudwara telling him of the attack. There were about 150 worshipers inside the Gudwara at the time of the attack, he added, according to AP.
The police are trying to dislodge the attackers, Khalsa said. The Interior Ministry said the first floor of the Gudwara had been cleared but that Afghan Special Forces, aided by international troops, were moving slowly throughout the remainder of the building.
The SITE Intelligence Group, which tracks militant postings and groups, said Daesh claimed responsibility for the attack on the group's Aamaq media arm.
At a Kabul hospital, Mohan Singh, who was in the Gudwara when the attack began, said he first heard the sound of gunshots and ran for cover under a table. Later he heard the sounds of explosions, adding that he believes they were hand grenades. He was injured when parts of the ceiling fell on him.
In photographs shared by the Interior Ministry, about a dozen children were seen being rushed out of the Gudwara by Afghan Special Forces, many of them barefoot and crying.
Earlier, as the news of the attack broke, Taliban spokesman Zabihullah Mujahed tweeted that the Taliban were not involved. Earlier this month, Afghanistan's Daesh affiliate struck a gathering of minority Shias in Kabul, killing 32 people.