KABUL (Reuters) - Islamic State claimed responsibility for a suicide attack on a crowded Shi’ite mosque in Kabul on Monday that killed more than 30 people and wounded dozens in its third major attack on minority Shi’ites in the Afghan capital since July.

Officials said the attacker entered the Baqir-ul-Olum mosque shortly after midday as worshippers gathered for Arbaeen, a Shi’ite ritual marking the end of a 40-day mourning period for the 7th century death of Imam Hussein, grandson of the Prophet Mohammad.

A statement in Arabic from Islamic State’s Amaq news agency said one of its fighters had targeted the mosque.

Bloody sectarian rivalry between Sunni and Shi’ite Muslims has been relatively rare in Afghanistan, a majority Sunni country, but the attack underlines the deadly new dimension that growing ethnic tension could bring to its decades-long conflict.

Fraidoon Obaidi, chief of the Kabul police Criminal Investigation Department, said at least 27 people were killed and 35 wounded, while the United Nations said at least 32 had been killed and more than 50 wounded, including many children. It described the attack as “an atrocity”.

“I saw people screaming and covered in blood,” one survivor told Afghanistan’s Ariana Television, adding that around 40 dead and 80 wounded had been taken from the building before rescue services arrived at the scene.

Another witness said he had helped carry 30-35 bodies from the mosque.

Slideshow ( 14 images )

Islamic State, based mainly in the eastern state of Nangarhar on the border with Pakistan, has gradually expanded its reach since emerging in Afghanistan last year with a reputation for hardline fundamentalism and brutality.

Prior to Monday’s attack, it had claimed responsibility for two major attacks on Shi’ite targets in Kabul, including a suicide bombing which killed more than 80 people at a demonstration by the mainly Shi’ite Hazara community, the worst single attack on civilians since 2001.

Last month, it also claimed an attack in which 18 people were killed when a gunman in police uniform opened fire on worshippers gathered at a shrine in Kabul for Ashura, one of the holiest occasions in the Shi’ite calendar.

In addition, at least 14 people were killed in an attack on a Shi’ite mosque in northern Balkh province, for which no group has so far claimed responsibility.

The Taliban, itself fiercely opposed to Islamic State, had already denied any involvement.

“We have never attacked mosques as it’s not our agenda,” said the movement’s main spokesman, Zabihullah Mujahid.

Slideshow ( 14 images )

Officials said the attack was a deliberate attempt to stoke sectarian tensions.

Any resurgence of sectarian or ethnic violence could threaten the fragile stability of the government headed by President Ashraf Ghani, who described the mosque blast as an attempt “to sow seeds of discord”.

Government Chief Executive Abdullah Abdullah said Afghanistan should not fall victim to “enemy plots that divide us by titles”.

“This attack targeted innocent civilians - including children - in a holy place. It is a war crime & an act against Islam & humanity,” he said in a message on his Twitter account.

Thousands of civilians have been killed in Afghanistan in the 15 years since the Taliban government was brought down in the U.S.-led campaign of 2001.

In July, the U.N. Assistance Mission in Afghanistan reported that 1,601 civilians had been killed in the first half of the year alone, a record since it began collating figures in 2009.