A suicide bomber blew himself up outside the embassy, allowing at least three other militants to breach the compound.
On Monday a suicide bomber blew himself up outside the embassy, allowing at least three other militants to breach the compound unleashing an hours-long gun battle.
Afghan officials initially said that no one had been killed in the assault, but the interior ministry later confirmed that two people -- a woman and a guard -- had died and two were policemen injured.
All embassy staff including Iraqi charge d'affairs were "unharmed", interior ministry spokesman Najib Danish said.
Security experts characterised the attack as a warning to Baghdad after it pushed IS out of Mosul, and said it could suggest a growing operational link between the jihadist group and its Afghan affiliate, Islamic State Khorasan Province (IS-K).
IS-K claimed responsiblity for the Kabul attack, according to a statement by IS's central propaganda agency Amaq.
It said two of its members attacked the embassy killing at least 27 guards and other embassy staff.
The militant group is known to often exaggerate its claims on the number of causalities inflicted.
IS has been expanding its footprint in eastern Afghanistan and has recently claimed responsibility for several devastating attacks in Kabul.
But experts have previously questioned whether there are direct links between IS-K and the central IS command.
"(Monday's attack) proves that IS threat in Afghanistan is real," said Kabul-based security analyst Jawed Kohistani, adding that the group could continue to attack diplomatic missions in the Afghan capital.
"To avenge its defeat in Iraq, IS and its supporters attacked Iraqi embassy in Kabul. It is easy for them to conduct more attacks on soft targets in Afghanistan again," Kohistani told AFP.
A security source, who declined to be named, said IS could prove to be more dangerous than the Taliban in Afghanistan.
Unlike the Taliban which has friends and foes among international community, IS considers everyone their enemy and will keep attacking soft targets, he said.
In April, the US military in Afghanistan dropped the so-called Mother Of All Bombs (MOAB) to target IS hideouts in a complex of tunnels and bunkers in eastern Nangarhar province, killing over 90 militants.
"The war (with IS) still goes on, its expanding and we need to be careful," Kohistani warned.