Twin attacks on the Iranian parliament and Ayatollah Khomeini’s mausoleum in the capital, Tehran, have killed at least 12 people and injured many more.
The assault on the parliament building appears to be over, after hours of intermittent, audible gunfire there. A suicide bomber died at the mausoleum.
Iranian officials say they managed to foil a third attack.
The so-called Islamic State group (IS) has claimed it carried out the attacks, which would be a first in Iran.
IS later posted a video which showed what it claimed was footage from inside the parliament building.
Iran attacks: As it happened
Iranian media reported that four attackers inside the parliament building had been killed by security forces.
It is not clear whether the death toll of 12 includes the attackers, or whether the victims were killed at both incidents or solely at the parliament.
About 40 people were injured in the two attacks, according to emergency services chief Pir Hossein Kolivand.
Gunmen armed with Kalashnikovs entered the parliament on Wednesday morning. Images from the scene showed a major security operation as forces surrounded the building.
Heavy gunfire could be heard.
Iranian authorities denied that there had been a hostage situation inside the parliament building.
Speaker Ali Larijani downplayed the events, describing it as a “minor issue”.
Reports said the gunmen had entered parliament via a public entrance, dressed as women.
At about 10:40 (06:10 GMT) attackers at the mausoleum in southern Tehran, which is dedicated to the Islamic Republic’s founder Ayatollah Khomeini, opened fire.
The governor of Tehran said one attacker there had detonated a suicide vest and another had been killed by security forces, state broadcaster Irib reports.
Images from the scene showed grenades and magazines for automatic weapons, apparently recovered from the body of an attacker.
The suicide attacker was a woman, reports suggested.
Several members of the public, visiting the shrine, have been injured.
Background – by Jenny Norton, BBC Persian
This is the most serious terrorist violence in Tehran since the turbulent early years after the 1979 Islamic Revolution.
It will come as a huge shock to ordinary Iranians, who have got used to living in a country which is generally far more stable and safe than most of its neighbours.
Despite Iran’s active involvement in fighting IS in both Iraq and Syria, the Sunni group has not so far carried out any attacks inside Iran, and appears to have little support in this predominantly Shia country.
However, in recent months the group has stepped up its Farsi-language propaganda efforts – targeting Iran’s restive Sunni minority, and the Iranian intelligence agencies claim to have foiled an number of IS-inspired plots.
Analysis – from BBC Monitoring’s Jihadist Media Team
IS has this year released a number of propaganda pieces focused on inciting attacks inside Iran.
An IS documentary-style video in March featured militants who were introduced as Iranian fighters in IS ranks based in Iraq.
Speaking in Farsi, they denounced the Iranian government and the religious establishment, including the country’s spiritual leader Ayatollah Ali Khamenei.
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.