Taliban militants stormed a government building in the center of the Afghan capital on Thursday and one of them blew himself up inside, killing five people, officials and witnesses said.

The assailants first opened fire on police guards outside the Ministry of Information and Culture before entering its cavernous hall where the explosion occurred, said Amir Mohammad, a police guard who was wounded in the blast.

"There were three people. They were running. They opened fire on our guard first and then they entered (the building)," Mohammad told The Associated Press from his hospital bed in Kabul.

Five people were killed in the attack, according to a statement from President Hamid Karzai's office. Another 21 were wounded in the explosion, said Abdul Fahim, the spokesman for the Health Ministry, which supervises the hospitals where the injured were taken.

The ministry is in the center of the city, at a busy intersection lined with shops.

One of the walls of the building collapsed, while glass littered the roads nearby and office equipment was scattered over the area.

The Taliban claimed responsibility for the attack and gave a similar account of what happened.

Zabiullah Mujahid, a Taliban spokesman, said three militants stormed the building by throwing hand grenades at the guards at the main gate.

A man named Naqibullah from the eastern Khost province carried out the homicide attack, Mujahid told the AP. The other two men fled, he said.

Abdul Rahim, a witness, said he first heard machine gun shots and saw a policeman lying on the ground and then saw the explosion that rocked the building.

Ministry workers were helped out of the building by security personnel. Ambulances carried the wounded to hospitals.

While insurgents regularly use homicide attacks against Afghan and foreign forces around the country, they have been rare in Kabul.

On July 7, a homicide attacker set off explosives outside the gates of the Indian Embassy in Kabul, killing more than 60 people, and wounding 146.