Iran says the attackers who killed 12 people in the capital Tehran were Iranians who had joined so-called Islamic State (IS).
Suicide bombers attacked parliament and the mausoleum of the Islamic Republic’s founder Ayatollah Khomeini.
All the attackers were killed. Five people believed to be planning a third attack were arrested, officials said.
Iran’s powerful Revolutionary Guards accused Saudi Arabia and the US of being behind the attacks.
The violence comes amid heightened tension in the Middle East, with Saudi Arabia and other Arab states cutting ties with Qatar over alleged support for Islamist militants and closer ties with Iran.
Sunni-ruled Saudi Arabia and Shia-majority Iran are staunch regional rivals.
In an interview on state TV, Reza Seifollahi, deputy chief of Iran’s Supreme National Security Council, said the attackers “had joined Daesh [IS] from a number of regions inside Iran.”
IS earlier claimed the attacks – a first for Iran – and threatened further assaults on Iranian Shia Muslims.
Iran’s Revolutionary Guards vowed revenge for the bloodshed, but pointed the finger at the US and Saudi Arabia in the wake of President Donald Trump’s recent visit to the kingdom.
“This terrorist action, coming one week 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 in this savage action,” it said in a statement.
The US and Saudi Arabia both condemned the attacks.
US President Donald Trump said he was praying for the victims but added that “states that sponsor terrorism risk falling victim to the evil they promote”.
What kind of presence does IS have in Iran?
Claiming the attack, IS posted a video which showed what it claimed was footage from inside the parliament building.
A voice is heard saying, in Arabic: “We’re not going anywhere. We’re staying forever.”
BBC Persian’s Jenny Norton says that despite Iran’s active involvement in fighting IS in both Iraq and Syria, the Sunni group has not until now carried out any attacks inside Iran, and appears to have little support in this predominantly Shia country.
However, our analyst says, in recent months the group has stepped up its Farsi-language propaganda efforts – targeting Iran’s restive Sunni minority.
Iranian intelligence agencies claim to have foiled a number of IS-inspired plots.
But by mounting a successful attack, IS could claim a major coup against a traditional foe that other Sunni jihadist groups, including its rival al-Qaeda, have failed to target in the past.
What is the likely effect of the attacks?
Middle East analyst Dina Esfandiary says one possible consequence will be increased calls by hardliners for tougher action against IS in Iraq and Syria.
Public support for action in Iraq is likely to grow, as it did when IS took swathes of territory in the country in 2014.
But Iran’s involvement in Syria is not popular, our analyst says – it is seen as having few benefits and costing too many Iranian lives.
The attacks will also boost the popularity of the Revolutionary Guards, seen as protectors of the nation.