Interior Ministry spokesman Najib Danish said 1 policeman was wounded and there were no fatalities among the security forces or civilians.
Kabul: The Islamic State group targeted the Iraqi Embassy in Kabul on Monday, with a suicide bomber blowing himself up outside the gates, followed by three gunmen who stormed into the building.
The assault set off a four-hour firefight that ended only after Afghan security forces had killed all the attackers.
There were conflicting reports of casualties as the attack unfolded, with a witness at the scene saying he saw bodies of at least two policemen lying on the road outside the embassy soon after the attack began.
In its claim of responsibility, the Islamic State group said its fighters had killed seven guards but the militant group often exaggerates its claims on the number of casualties inflicted. The IS attack likely meant to distract attention from the militants' massive losses in Iraq and Syria in recent weeks.
Interior Ministry spokesman Najib Danish said only one policeman was wounded and that there were no fatalities among the security forces or civilians.
Danish told The Associated Press 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.
In Baghdad, the Foreign Ministry spokesman Ahmad Jamal condemned the assault as a "terrorist attack".
The attack began with a big explosion that rocked central Kabul shortly before noon, followed by gunfire that lasted for several hours, and two or three more subsequent large explosions. Police quickly cordoned off the area, barring reporters from coming too close to the scene.
The Afghan Interior Ministry said a suicide bomber first started the attack, blowing himself up at the embassy gate, after which three attackers stormed inside.
Earlier, Afghan officials who spoke on condition of anonymity as they were not authorized to talk to the media, had said a car bomb started the assault. Later on, it became clear the suicide bomber was on foot and not driving a car.
The ministry statement said Afghan security forces quickly deployed to the scene, rescuing all the embassy diplomats and employees and taking them to safety.
While the attack was still underway, the Islamic State affiliate in Afghanistan claimed responsibility in a statement carried by the IS-linked Aamaq news agency.
A police officer in the area, who identified himself only as Abdullah, said the gunfire was initially intense but later became more sporadic. The area was surrounded by armoured vehicles and a large contingent of police and Afghan soldiers.
At least one 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 armored personnel carriers and police arrived to cordon off the area.
More than an hour into the attack, witnesses reported hearing another powerful explosion and said they saw black smoke billowing skyward. It wasn't immediately clear what had caused the later explosion.
"The explosion was so strong. I was so afraid," said Maryam, a woman crying near the site of the attack said. She said she works at the nearby office of Afghanistan's National Airline Ariana.
The Iraq Embassy is located in a part of the city known as Shahr-e-Now, 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.
By comparison, the Iraqi Embassy is located on a small street in a neighborhood dominated by markets and businesses.
After Iraqi forces, backed by a US-led coalition, recaptured the city of Mosul from the Islamic State group earlier in July, the Iraq Embassy had called reporters to its offices in Kabul to express concerns that the local IS affiliate might stage large-scale attacks elsewhere to draw away attention from the militant group's losses in Iraq.