A suicide bomber targeted a gathering of Muslim religious scholars in the Afghan capital on Tuesday, killing at least 40 people, Afghan officials said.

Public Health Ministry spokesman Wahid Majroh said another 60 people were wounded in the attack, which took place as Muslims around the world marked the birthday of the Prophet Muhammad. He said the toll could rise.

The suicide bomber was able to sneak into a wedding hall in Kabul where hundreds of religious scholars and clerics had gathered to mark the occasion.

A man injured in a suicide bombing is brought into a hospital for treatment, in Kabul, Afghanistan, Nov. 20, 2018. Afghan officials said the suicide bomber targeted a gathering of Muslim religious scholars in Kabul, killing at least tens of people. A Public Health Ministry spokesman said another 60 people were wounded in the attack, which took place as Muslims around the world marked the birthday of the Prophet Mohammad. (AP PhotoRahmat Gul)

A man injured in a suicide bombing is brought into a hospital for treatment, in Kabul, Afghanistan, Nov. 20, 2018. Afghan officials said the suicide bomber targeted a gathering of Muslim religious scholars in Kabul, killing at least tens of people. A Public Health Ministry spokesman said another 60 people were wounded in the attack, which took place as Muslims around the world marked the birthday of the Prophet Mohammad. (AP PhotoRahmat Gul)

"The victims of the attack unfortunately are all religious scholars who gathered to commemorate the birthday of Prophet Muhammad," said Basir Mujahid, spokesman for the Kabul police chief. He said police had not been asked to provide security for the event, and that the bomber had easily slipped into the hall.

No one immediately claimed the attack, but both the Taliban and a local Islamic State affiliate have targeted religious scholars aligned with the government in the past.

IS claimed a suicide bombing in June that targeted a meeting of the country's top clerics in the capital. That attack killed at least seven people and wounded 20. The body of religious leaders, known as the Afghan Ulema Council, had issued a decree against suicide attacks and called for peace talks.

A man injured in a suicide bombing is brought into a hospital for treatment, in Kabul, Afghanistan, Nov. 20, 2018. Afghan officials said the suicide bomber targeted a gathering of Muslim religious scholars in Kabul, killing at least tens of people. A Public Health Ministry spokesman said another 60 people were wounded in the attack, which took place as Muslims around the world marked the birthday of the Prophet Mohammad. (AP PhotoRahmat Gul)

A man injured in a suicide bombing is brought into a hospital for treatment, in Kabul, Afghanistan, Nov. 20, 2018. Afghan officials said the suicide bomber targeted a gathering of Muslim religious scholars in Kabul, killing at least tens of people. A Public Health Ministry spokesman said another 60 people were wounded in the attack, which took place as Muslims around the world marked the birthday of the Prophet Mohammad. (AP PhotoRahmat Gul)

IS said it had targeted "tyrant clerics" who were siding with the U.S.-backed government.

The Taliban denied involvement in the June attack but they also denounced the gathering.

Both militant groups want to overthrow the U.S.-backed government and impose a harsh form of Islamic rule, but they are bitterly divided over leadership and ideology, and they have clashed on a number of occasions.