However, the security forces rescued around 80 worshippers from the Gurudwara.
At least one attacker was subsequently killed by security forces in an hours-long clearing operation.
The security forces have cordoned off the area, located in old Kabul, and are trying to counter the attack. That agreement, which laid the groundwork for the withdrawal of USA troops, has been followed by a spate of attacks by the Taliban - which denied responsibility for Wednesday's assault - and ISIS, another major Islamist militant group in the region whose activities the Taliban pledged to try to curb. Wednesday's slaughter was the second Isis attack on a religious minority this month; a gathering of the predominantly Shia Hazara ethnic minority was also attacked earlier in March, with more than 30 people killed.
The Afghanistan officials also said that 11 children have been rescued from the gurudwara.
Several of the worshippers were being held hostage by the gunmen who were lobbing grenades at the Afghan special forces, Khalsa said, but added he couldn't say how many were being held.
"This attack is clear message to India and a signal to curtail indian influence in Afghanistan in the near future", said another officer. According to some reports, 150 people were inside the gurudwara when the attack took place. The Sikhs constitute a minuscule minority in Afghanistan.
The group issued a statement confirming that its members carried out the attack on Sikhs in Kabul city, Khaama Press News Agency reported.
The United States last month struck a deal with the Taliban on the withdrawal of USA -led worldwide troops but the agreement does not include IS militants.
The Islamic State militant group claimed responsibility for the attack in a statement.
War-torn Afghanistan is now mired in a political stalemate with two politicians- Ashraf Ghani and Abdullah Abdullah - both claiming victory in the presidential election.
The Taliban group announced that the Islamic Emirate is not involved in today's attack on Sikh temple in Kabul city.
Afghanistan has seen no relief from violence in the weeks following the announcement of a peace framework between the US and the Taliban. Amnesty International South Asia tweeted: "We are shocked and disheartened.the authorities have a responsibility to protect minorities and their places of worship in Afghanistan".