KABUL -- A lone Islamic State gunman rampaged through a Sikh house of worship in the heart of the Afghan capital Wednesday, killing 25 worshippers and wounding eight, Afghanistan's Interior Ministry said.

The gunman held many worshippers hostage for several hours while Afghan special forces, helped by international troops, tried to clear the building. At least one of the dead was a child.

Within hours, the Islamic State group claimed responsibility for the attack.

The Afghan special forces rescued at least 80 worshippers who had been trapped inside the Sikh house of worship, known as a Gurdwara, as the gunman lobbed grenades and fired his automatic rifle into the crowd, the ministry said.

Earlier, Afghan lawmaker Narindra Singh Khalsa said he rushed over to help after receiving a call from a person inside the Gurdwara telling him of the attack. There were about 150 people inside at the time, he said.

The SITE Intelligence Group, which tracks militant postings and groups, said IS claimed responsibility for the attack on the group's Aamaq media arm. The communique identified the gunman as Indian national Abu Khalid al-Hindi, who carried out the attack to avenge the plight of Muslims living under severe restrictions in Indian-ruled Kashmir, Hindu India's only Muslim dominated state.

At a Kabul hospital, Mohan Singh, who was in the Gurdwara when the attack began, said he first heard the sound of gunshots and ducked for cover under a table. Later he heard explosions, adding that he believes they were hand grenades. He was wounded 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 Gurdwara by Afghan special forces, many of them barefoot and crying.

As news of the attack first broke, Taliban spokesman Zabihullah Mujahed tweeted that the Taliban were not involved. Earlier this month, Afghanistan's IS affiliate struck a gathering of minority Shiite Muslims in Kabul, killing 32 people.

Afghanistan's National Security Adviser Hamdullah Mohib condemned the attack in a tweet while neighbouring Pakistan and India both issued statements of condemnation. Pakistan described the attack as "heinous."

"Such despicable acts have no political, religious or moral justification and must be rejected outright," the Pakistani Foreign Ministry statement said.

India said the attack was particularly egregious coming as Afghanistan sought to deal with the growing coronavirus pandemic.

"Such cowardly attacks on the places of religious worship of the minority community," India said, reflect the "diabolical mindset of the perpetrators and their backers."

U.N. Secretary-General Antonio Guterres condemned the attack, reiterating that "attacks against civilians are unacceptable and those who carry out such crimes must be held accountable," U.N. spokesman Stephane Dujarric said.

The United Nations Assistance Mission in Afghanistan called for a "reduction of violence leading to a cease-fire" by all combatants in Afghanistan

Sikhs have suffered widespread discrimination in the conservative Muslim country and have also been targeted by Islamic extremists. Under Taliban rule in the late 1990s, they were asked to identify themselves by wearing yellow armbands, but the rule was not enforced. In recent years, large numbers of Sikhs and Hindus have sought asylum in India, which has a Hindu majority and a large Sikh population.

In July 2018, a convoy of Sikhs and Hindus was attacked by an Islamic State suicide bomber as they were on their way to meet Afghan President Ashraf Ghani in the eastern city of Jalalabad, the capital of Nangarhar province. Nineteen people were killed in that attack.

Elsewhere in Afghanistan, at least eight civilians were killed in southern Helmand province when their vehicle hit a roadside mine, said Omer Zwak, spokesman for the provincial governor. The area is under Taliban control but no one took immediate responsibility.

In a separate incident in northern Kapisa province, insurgents opened fire on a vehicle killing three civilians and a security officer, said Shahiq Shoresh Kohistani, spokesman for the provincial police chief.

Washington signed a deal with the Taliban on Feb. 29 and has begun to withdraw its troops in keeping with the agreement but it has run into trouble as Afghanistan's political leadership battles relentlessly for power. Two presidents sit in Kabul. Even a surprise visit by U.S. Secretary of State Mike Pompeo on Monday, who threatened to withhold $1 billion in aid if they didn't "get their act together," could break the impasse.

A glimmer of hope appeared late Wednesday with a tweet from Taliban political spokesman Sohail Shaheen. He said the release of Taliban prisoners -- a must before intra-Afghan negotiations can begin -- could start by March 31. The decision came after a four-hour video conference between the Taliban, the government, Washington's peace envoy Zalmay Khalilzad and the Qatari government representative. The Taliban maintain a political office in the Middle Eastern State of Qatar.

The U.S.-Taliban deal calls for the release of 5,000 Taliban prisoners as well as 1,000 government captives as a good will gesture to launch intra-Afghan negotiations, but until now Kabul has been resisting the release.

Shaheen also said four Taliban members may travel to the prison at Bagram, north of the Afghan capital Kabul.

Meanwhile, with more than 137,000 Afghans returning from Iran so far this year -- travelling throughout the country before being tested and without follow up -- there have been concerns that the country's already war-devastated health system could be overwhelmed.

The United Nations Assistance Mission in Afghanistan (UNAMA) on Wednesday called for a "reduction of violence leading to a cease fire" by all combatants in Afghanistan to better prepare for "the looming health crisis posed by COVID-19," and to give a chance to intra-Afghan negotiations between warring groups.

--------------

Associated Press writers Kathy Gannon in Islamabad and Jon Gambrell in Dubai, UAE contributed to this report