The group also claimed responsibility for an attack Tuesday that killed at least 29 and wounded more than 63 at a Shi'ite mosque in Herat, an area in western Afghanistan that had previously escaped ISIS' sectarian attacks.
The choice of target in the Iraqi embassy attack, three weeks after the fall of Mosul to Iraqi troops, appeared to back up repeated warnings from Afghan security officials that, as ISIS terrorists were pushed out of Syria and Iraq, they risked showing up in Afghanistan.
"This year we're seeing more new weapons in the hands of the insurgents and an increase in numbers of foreign fighters," said Afghan Defence Ministry spokesman Gen. Dawlat Waziri. "They are used in front lines because they are war veterans."
One senior security official put the number of foreigners fighting for both ISIS and the Taliban in Afghanistan at roughly 7,000, most operating across the border from their home countries of Pakistan, Uzbekistan or Tajikistan, but also including others from countries such as India.
While such foreign fighters have long been present in Afghanistan, there has been growing concern that militants from Arab countries, who have left the fighting in Syria as pressure on ISIS there has grown, have also been arriving in Afghanistan through Iran.
"We are not talking about a simple militant fighter, we are talking about battle-hardened, educated and professional fighters in the thousands," another security official said. "They are more dangerous because they can and will easily recruit fighters and foot soldiers here."
The United States, which first came to Afghanistan in 2001 after Al Qaeda's attacks on New York and Washington, is considering sending more troops to Afghanistan, in part to ensure the country does not become a haven for foreign militant groups.
But while Afghan and US officials have long warned of the risk that foreign fighters from Syria could move over to Afghanistan, there has been considerable scepticism over how many have actually done so.
In April, during a visit to Kabul by US Defence Secretary James Mattis, the commander of NATO forces in Afghanistan, Gen. John Nicholson, said that, while ISIS had an "aspiration" to bring in fighters from Syria, "we haven't seen it happen".
"New tactics, weapons"
US commanders say that, in partnership with Afghan security forces, they have severely reduced ISIS' strength over the past year with a combination of drone strikes and Special Forces operations.
"In recent operations, we have inflicted heavy losses on them but their focus is to recruit fighters from this area," said Juma Gul Hemat, police chief of Kunar, an eastern province where ISIS fighters pushed out of their base in neighbouring Nangarhar have increasingly sought refuge.
"They are not only from Pakistan or former Taliban, there are fighters from other countries and other small groups have pledged their allegiance to them," he said.
Afghan officials say newly arrived foreign fighters have been heavily involved in fighting in Nangarhar province, ISIS' main stronghold in Afghanistan, where they have repeatedly clashed with the Taliban.
Security officials say they are still investigating Monday's embassy attack and it is too early to say whether there was any foreign influence or involvement.
ISIS put out a statement identifying two of the attackers as Abu Julaybib Al-Kharasani and Abu Talha Al-Balkhi, Arabic names that nonetheless suggest Afghan origins. Khorasan is an old name for the Central Asian region that includes Afghanistan, while Balkh is a province in northern Afghanistan.
What little contact is possible with fighters loyal to ISIS in Afghanistan suggests that the movement itself is keen to encourage the idea that foreign militants are joining its ranks.
"We have our brothers in hundreds from different countries," said an ISIS commander in Achin district of Nangarhar.
"Most of them have families and homes that were destroyed by the atrocity and brutality of the infidel forces in Arab countries, especially by the Americans," he said. "They can greatly help us in terms of teaching our fighters new tactics, with weapons and other resources."
(Editing by Alex Richardson)