“These fire-crackers that happened today will not have the slightest effect on the will of the people,” Ayatollah Ali Khamenei said after the twin attacks, which also left dozens injured.
The attackers struck at Iran’s most potent symbols: its parliament complex in central Tehran and the mausoleum of Ayatollah Ruhollah Khomeini who led the 1979 Islamic revolution.
President Hassan Rouhani called for global unity against violent extremism.
“Iran’s message as always is that terrorism is a global problem, and unity to fight extremism, violence and terrorism with regional and international cooperation is the most important need of today’s world,” he said in a statement.
The country’s powerful Revolutionary Guards vowed revenge and claimed the United States and Saudi Arabia were “involved”.
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, suggesting a degree of coordination.
The Sunni jihadists of IS consider Shiite Iran to be apostates, and Tehran is deeply involved in fighting the group in both Syria and Iraq.
The assaults began mid-morning when four gunmen burst into the parliament complex, killing a guard and one other person, according to the ISNA news agency.
The parliament attackers were in their early 20s and spoke Arabic, according to a Revolutionary Guards intelligence official.
Another 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.
One man, recovering in a hospital bed, told state TV he was waiting to meet an MP when the shooting began.
“I was in the visitors’ lobby and suddenly shooting began. There were women and children. I escaped towards the parliament, and was shot in the leg while running,” he said.
At roughly the same time, two assailants entered the grounds of the Khomeini mausoleum, killing a gardener and wounding several other people.
One detonated a suicide vest, while the other was shot dead.
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 13 people were killed in the two attacks and 46 wounded.
In a statement after the attacks, the Guards said they “will never allow the blood of innocents to be spilt without revenge”.
“This terrorist action... after the meeting of the president of the United States with the leader of the one of the region’s reactionary governments (Saudi Arabia)... shows they are involved,” it added, referring to US President Donald Trump’s recent visit to Riyadh.
Washington condemned the attacks, with State Department spokeswoman Heather Nauert saying: “The depravity of terrorism has no place in a peaceful, civilised world.”
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.
Meanwhile, gunshots continued in the neighbouring office buildings, with police helping staff to escape from windows and snipers taking position from rooftops.Speaker Ali Larijani dismissed the attacks, saying they were a “trivial matter”.