By Agence France-Presse
Wednesday's attacks on Tehran's parliament complex and the shrine of revolutionary leader Ayatollah Ruhollah Khomeini, which also wounded more than 50 people, were the first claimed by IS in Iran.
"The five known terrorists... after joining the Daesh (IS) terrorist group, left the country and participated in crimes carried out by this terrorist group in Mosul and Raqa," the intelligence ministry said in a statement.
It suggested there were only five attackers rather than the six originally reported.
An official said previously that those who attacked the parliament complex had been dressed as women.
The ministry released their photographs and first names.
It said they were part of a network that entered Iran in July-August 2016 under the leadership of "high-ranking Daesh commander" Abu Aisha intending to carry out "terrorist operations in religious cities".
Abu Aisha was killed and the network forced to flee the country, the statement said. It was unclear when the five men returned to Iran ahead of Wednesday's attacks.
IS on Thursday released a video of the five attackers before the assault, via its Amaq propaganda agency.
"Allah permitting, this is the first brigade that was established (in Iran) but it will not be the last," one said in the video message, as the group sat masked in a circle with their weapons.
The jihadist group had earlier released footage of the attackers from inside the building, also via Amaq -- a rare claim of responsibility while an assault was still going on.
'The evil they promote'
Following the attacks, US President Donald Trump said the United States would "grieve and pray" for the victims, but added: "We underscore that states that sponsor terrorism risk falling victim to the evil they promote."
The statement was condemned by foreign Minister Mohammad Javad Zarif, who tweeted: "Repugnant WH (White House) statement... as Iranians counter terror backed by US clients."
Trump was also criticised on social media by Iranians, who recalled their government's offers of support and the candlelight vigils held in Iran after the attacks of September 11, 2001 in the United States.
"Iranians lit candles for you on 9/11. You kick them while they're down. Classy," tweeted Ali Ghezelbash, an Iranian business analyst.
The US president has long accused Iran of backing terrorism and has threatened to tear up a 2015 nuclear deal between Tehran and major powers.
Even as Washington expressed its condolences on Wednesday, the US Senate advanced legislation to impose new sanctions on Iran, partly for what the bill described as the regime's "support for acts of international terrorism".
Iran's elite Revolutionary Guards have pointed the finger at regional rival Saudi Arabia -- a close US ally -- which Tehran accuses of funding extremism and groups including IS.
IS has threatened to step up recruitment within Iran, releasing its first Persian-language video in March in which it threatened to "conquer Iran and restore it to the Sunni Muslim nation as it was before."
The Sunni jihadists of IS consider Shiite Iranians to be apostates, and Tehran is deeply involved in fighting the group in both Syria and Iraq.
Khomeini shrugs off attacks
The attackers were armed with rifles and pistols and at least two blew themselves up with suicide vests, Iranian media reported.
Police said a further five people were arrested around Khomeini's shrine on suspicion of involvement.
In the midst of the unfolding attacks, the intelligence ministry said a third team had been stopped before the attacks started, but no further details have since been given.
Sunni Gulf Arab states are in the midst of a major diplomatic crisis after Saudi Arabia and its allies cut ties with Qatar on Monday over claims it supports extremism and has fewer tensions with Iran.
Iranian leaders sought to play down the attacks, with supreme leader Ayatollah Ali Khamenei saying: "These firecrackers that happened today will not have the slightest effect on the will of the people."