A suicide bomber killed at least five people outside the Afghan foreign ministry on Wednesday, police said, and a nearby hospital said over 40 people were wounded.

Kabul police spokesperson Khalid Zadran said the official confirmed death toll was five.

Ustad Fareedun, an official at the Taliban-run information ministry, said 20 people were killed. He said the bomber had planned to enter the foreign ministry but failed.

Emergency Hospital, a surgical centre for those wounded by the war run by an Italian NGO, said it had received more than 40 patients following the explosion.

The United Nations and several countries, including Pakistan and the United Kingdom, condemned the attack.

"The UK rejects such senseless and indiscriminate acts of violence," said Hugo Shorter, the charge d'affaires for the UK mission to Afghanistan.

A photo of the area, confirmed by official sources, showed at least nine dead or wounded lying outside the ministry.

The blast hit at about 4 p.m. (1130 GMT), Zadran said.

Islamic State claimed responsibility for the attack, the militant group's Amaq news agency said in an affiliated Telegram channel.

The Taliban-run administration has faced an insurgency by Islamic State militants who have targeted foreigners, including the Russian and Pakistani embassies and a hotel catering to Chinese businessmen.

The blast took place during a busy time of day in a heavily fortified area surrounded by checkpoints on a street housing several ministries. Some countries, including Turkey and China, have embassies in the area.

No country has formally recognised the administration of the Taliban, which took over Afghanistan in August 2021 with a speed and ease that took the world by surprise, following which President Ashraf Ghani fled the country and his government collapsed. (Mohammad Yunus Yawar in Kabul and Jibran Ahamad in Peshawar; additional reporting by mahmoud Mourad and Ahmed Tolba in Cairo; writing by Shivam Patel and Charlotte Greenfield; Editing by Andrew Heavens, Paul Simao, Angus MacSwan, William Maclean, Nick Macfie, Bernadette Baum, William Maclean)