A company driver waiting outside saw a man holding a bag and with a rifle slung over his shoulder walk past before the man blew himself up.

"He passed by my car and after a few seconds there was a loud blast," Jamshed Karimi said, adding he saw 20 to 25 causalities.

"I saw the man blowing himself up."

Kabul police spokesman Khalid Zadran confirmed the blast, "which unfortunately resulted in casualties".

In the aftermath, bodies lay strewn on the road outside the high-walled compound of the ministry, marked with the Taliban flag, a video verified by AFP showed.

Some injured people writhed on the ground, screaming for help, and a handful of onlookers scrambled to offer assistance.

The ministry itself did not appear to be badly damaged. Window panes in the interior ministry were also shattered by the impact of the blast.

"There was supposed to be a Chinese delegation at the Foreign Ministry today, but we don't know if they were present at the time of the blast," deputy minister of information and culture Muhajer Farahi told AFP.

However, Ahmadullah Muttaqi, a senior official at the prime minister's office, said no foreigners were present at the ministry when it was attacked.

Attacks targeting foreigners

IS has claimed a string of attacks that have targeted foreigners or foreign interests in recent months, at a time when the Taliban is trying to attract investment from neighbouring countries.

At least five Chinese nationals were wounded last month when gunmen stormed a hotel popular with Chinese business people in Kabul.

That raid was claimed by IS, who also took responsibility for an attack on Pakistan's embassy in Kabul in December that Islamabad denounced as an "assassination attempt" against their ambassador.

Neighbouring China is one of the few nations to maintain diplomatic ties with Afghanistan's new rulers, saying it was ready for "friendly and cooperative" relations after the Taliban entered Kabul on August 15, 2021.

Beijing has not recognised the Taliban government but has been eyeing investment in Afghanistan's ample mineral deposits, which were largely impossible to exploit during the 20-year war that followed the end of the Taliban's previous reign in late 2001.

Four people were killed and 25 wounded in an attack on a mosque in the grounds of the interior ministry in Kabul in October, with survivors reporting it was a suicide bombing.

And two Russian embassy staff members were killed in a suicide bombing outside their mission in September in another attack claimed by IS.

Hundreds of people, including members of Afghanistan's minority communities, have been killed and wounded in other attacks since the Taliban regained power.

Afghanistan's regional chapter of the Islamic State group is known as Islamic State-Khorasan (IS-K), a historical term describing the vast territory they hope to rule spanning India, Iran and Central Asia.

The Taliban and IS-K share an austere Sunni Islamist ideology but the latter are crusading to establish a global "caliphate" instead of the Taliban's more modest and inward-looking goal of ruling an independent Afghanistan.