Gunmen and suicide bombers stormed Iran's parliament and the shrine of its revolutionary leader on Wednesday, killing 12 people in the first attacks in the country claimed by ISIS.
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.
In a statement after the attacks, 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.
The country's powerful Revolutionary Guards vowed revenge for the attacks 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.
ISIS 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 ISIS 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.
'Suddenly shooting began'
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 12 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.
Foreign Minister Mohammad Javad Zarif said the attacks would "certainly reinforce the determination of Iranians to fight against terrorism".
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 neighboring 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".
The intelligence ministry said there had been a third "terrorist" team that was neutralized before the attacks started.
Tehran was on lockdown, with streets blocked and parts of the metro closed.
Others also drew a link to Trump's visit to Saudi Arabia, which Iran accuses of funding IS.
"For these two actions to happen... after this meeting means that the US and Saudi regimes had ordered their stooges to do this," said Mohammad Hossein Nejat, deputy head of the Revolutionary Guards intelligence branch, according to the Fars news agency.
Targeted by ISIS
Messages of support were sent by Russian President Vladimir Putin and the Syrian foreign ministry.
The three countries are close allies in the fight against rebels and jihadist groups in Syria. Iran has also been helping to battle ISIS 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 centers.
The intelligence ministry said in June 2016 that it had foiled an ISIS plot to carry out multiple bomb attacks in Tehran and around the country.
Tasnim News Agency/Reuters