Dozens were injured in the attacks, which targeted two of Iran's most potent symbols: its parliament complex in central Tehran and the mausoleum of Ayatollah Ruhollah Khomeini who led the 1979 Islamic revolution.
The standoff lasted around five hours before all the gunmen holed up in parliamentary office buildings were killed.
IS released a video of the attackers from inside the building via its Amaq propaganda agency -- a rare claim of responsibility while an attack was still going on.
The assaults began mid-morning when four gunmen burst into the parliament complex in the centre of Tehran, killing a security guard and one other person, according to the ISNA news agency.
Also Read
An interior ministry official said they were dressed as women and entered through the visitors' entrance. One eventually exploded a suicide vest while the others were killed by security forces.
At roughly the same time, two assailants entered the grounds of the Khomeini mausoleum, killing a gardener and wounding several other people.
It was not clear whether the shrine attackers were women, as earlier reported, or just wearing female clothing.
Iran's emergency services said a total of 12 people were killed in the two attacks and 43 wounded.
Iran's leaders sought to play down the attacks, with neither President Hassan Rouhani nor supreme leader Ayatollah Ali Khamenei making a statement by early evening.
Parliament was in session as the violence unfolded and members were keen to show they were undeterred, posting selfies showing themselves as calm and continuing with regular business.
Speaker Ali Larijani dismissed the attacks, saying they were a "trivial matter" and that security forces were dealing with them.
The intelligence ministry said there had been a third "terrorist" team that was neutralised before the attacks started.
Tehran was on lockdown, with streets blocked and parts of the metro closed. Journalists and onlookers were kept away from the sites by police.
Interior Minister Abdolrahman Fazli told ISNA he had convened a special meeting of the country's security council.
The three countries are close allies in the fight against rebels and jihadist groups in Syria. Iran has also been helping to battle IS in Iraq, which also sent its condolences.
This has made Iran, the predominant Shiite power, a priority target for IS, which published a rare video in Persian in March warning that it "will conquer Iran and restore it to the Sunni Muslim nation as it was before."
Jihadist groups have clashed frequently with Iranian security forces along the borders with Iraq and Afghanistan, but the country has largely escaped attacks within its urban centres.
IS is under increasing pressure, having lost significant territory in the face of offensives now targeting its last two major urban bastions, Raqa in Syria and Mosul in Iraq.
Militant groups are also known to operate in Iran's southeastern Sistan-Baluchistan province, which borders Pakistan and has a large Sunni community.
Jaish-ul Adl (Army of Justice), which Tehran accuses of links with Al-Qaeda, has carried out several armed attacks on Iranian soil in recent years.
"This is a fire that (Western powers) themselves ignited and now has backfired on them," he told a gathering of senior officials in Tehran.
Disclaimer: No Business Standard Journalist was involved in creation of this content