KABUL (Reuters) - Militant group Islamic State claimed responsibility for an attack on the Iraqi embassy in Kabul on Monday that began with a suicide bomber blowing himself up at the main gate, allowing gunmen to enter the building and battle security forces.

Although there has been no confirmation of direct planning links with the main Islamic State movement in Iraq and Syria, the attack, just three weeks after the recapture of Mosul, underlines fears of a spillover into Afghanistan from fighting in Syria and Iraq.

Afghan security forces confronted three gunmen for hours before the Interior Ministry announced in mid-afternoon that the attack, in a normally busy business district of the capital, had been suppressed.

“The attack is finished,” said Sayed Basir, a member of the special forces unit that dealt with the incident. He said the four attackers were dead, while two members of his unit were slightly wounded.

The embassy building, partly blackened by smoke and flames from the fighting, was damaged but otherwise the impact from the attack was relatively limited, compared with other recent attacks in Kabul.

Najib Danish, an Interior Ministry spokesman, said two Afghan embassy workers had been killed but no Iraqi personnel had been hurt.

A separate statement from the Iraqi Foreign Ministry said an Iraqi diplomat had been rescued, while a nearby hospital operated by Italian aid group Emergency said two injured people had been brought in for treatment.

Islamic State’s Amaq agency said two attackers carrying machine guns and hand grenades and wearing suicide vests had blown up the gate, and two fighters had broken into the compound. It said more than 27 guards had been killed, well above the figures given by Afghan authorities.

The assault came a week after 35 people were killed in a Taliban attack on government workers in Kabul and underlines Afghanistan’s precarious security as the United States weighs an overhaul of its policy in the region.

Slideshow ( 12 images )

Islamic State, an ultra-hardline Sunni group, has carried out a series of high-profile attacks in Kabul, mainly targeting members of the mainly Shi’ite Hazara community. The attacks have fueled fears that militants in Afghanistan are trying bring in the kind of sectarian brutality seen in the Middle East.

The local branch of the movement, often called Daesh, is often known as Islamic State in Khorasan (ISIS-K), after an old name for the region that now includes Afghanistan.

The top U.S. commander in Afghanistan, Gen. John Nicholson, condemned the attack. “ISIS-K seeks only to destroy a peaceful future for the people of Afghanistan. They failed in this attack and they will be defeated,” he said in a statement.

U.S. commanders say ISIS-K has been severely hit by a campaign of drone strikes and joint Afghan and U.S. Special Forces operations over the past year, with hundreds of fighters and commanders killed.

However, Afghan security officials say the movement operates in as many as nine provinces, from Nangarhar and Kunar in the east to Badakhshan, Jawzjan and Faryab in the north and Baghdis and Ghor in the west.

The Taliban, fighting to reestablish strict Islamic law 16 years after being expelled by a U.S.-led campaign in 2001, have opposed Islamic State.