Suicide bomb explosion was followed by four hours of gunfight that ended after Afghan forces killed all attackers.

The Islamic State of Iraq and the Levant (ISIL) group has claimed responsibility for a suicide bombing and a gun attack on the Iraqi embassy in Afghanistan’s capital, Kabul.

A suicide bomber blew himself up outside the gates of the embassy on Monday before three gunmen stormed into the building, setting off a four-hour firefight that ended after Afghan security forces killed all attackers.

Interior Ministry spokesman Najib Danish told reporters that two Afghan employees of the Iraq embassy died in the attack. Three police were injured.

Initial reports suggested that the suicide bomber was in a car, but later on it became clear that the attacker was on foot.

ISIL, also known ISIS, claimed its fighters killed seven guards, but Afghanistan’s interior ministry spokesman Najib Danish said only one police officer was injured in the assault.

Danish told the AP news agency over the phone that all the embassy staffers were safe, but that the building had suffered extensive damage with windows broken and several rooms badly burned.

“We heard two explosions near the Iraqi embassy and part of the building has been damaged,” Mohsen Negaresh, a witness, told Al Jazeera.

At least one other eyewitness, a store owner who goes by the name of Hafizullah – many Afghans use only one name – said he saw the bodies of two policemen on the ground before armoured personnel carriers and police arrived to cordon off the area.

READ MORE: UN condemns jump in Afghan civilian deaths

The Iraqi embassy is located in a part of the city known as Shahr-e-Naw, which lies outside the so-called Green Zone where most foreign embassies and diplomatic missions are located and which is heavily fortified with a phalanx of guards and giant cement blast walls.

Instead, the embassy is located in a residential area with homes, schools, shops and restaurants.

“It is usually very busy in this area. It was shut down today as that gunfire went on,” Al Jazeera’s Jennifer Glasse, reporting from Kabul, said.

“I think Iraqis were caught very much by surprise. Their embassy is not in the Green Zone. It was on the main street with people and traffic going by.”

She said Afghans were very upset with the government, especially in Kabul, asking why it is not able to protect them even in the capital.

“Security was beefed up in Kabul in the last couple of weeks in the wake of the May 31 truck bombing that killed 150 people, but ISIL still managed to get in with a suicide vest and a lot of ammunition that let them hold fire for several hours,” Glasse said.

The attack comes a week after at least 35 people were killed in a Taliban-claimed suicide attack on government workers in Kabul and underlines the precarious security in Afghanistan as the US administration considers an overhaul of its policy in the region.

“We will hunt them down until they are no longer a threat to the Afghan people and the region,” he said.

ISIL is believed to be on the back foot in the Middle East, where analysts have said it has lost more than 60 percent of its territory and 80 percent of its revenue, three years after declaring its self-styled “caliphate” across swaths of Iraq and Syria.

NATO forces ended their combat mission in Afghanistan at the end of 2014. Since then, Afghan troops and police, beset by soaring casualties, have struggled to beat back the fighters.

The US is considering whether to send thousands more troops to help Afghan forces as the country is gripped by increasing insecurity.