Iran's supreme leader shrugged off attacks on Wednesday by gunmen and suicide bombers in Tehran that killed 13 people as US president Donald Trump warned the nation was reaping what it sowed.
The assault was the first claimed by the Islamic State group in Iran, and was the worst terror strike to hit the nation in years.
"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.
While Trump expressed sympathy for the victims he leveled a barbed warning at the nation, which the US leader took a hardline on during a recent Middle East visit.
"We underscore that states that sponsor terrorism risk falling victim to the evil they promote," he said in a short statement.
Footage of the Iran shrine blast
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.
Speaking earlier on Wednesday, Iran's 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 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 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.
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".
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.
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 IS
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 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.
The intelligence ministry said in June 2016 that it had foiled an IS plot to carry out multiple bomb attacks in Tehran and around the country.