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 appears to be over, after hours of intermittent gunfire there. A suicide bomber detonated a device at the mausoleum.
Iranian officials say they managed to foil a third attack.
The Islamic State group (IS) has claimed it carried out the attacks, which would be a first in Iran.
Five suspects have been arrested in Tehran, the city's police chief said.
Gunmen armed with Kalashnikovs entered the parliament on Wednesday morning. Heavy gunfire could be heard, and there were eports that a security guard has been killed.
Images from the scene showed a major security operation as forces surrounded the building.
Iranian authorities denied that there had been a hostage situation inside the parliament building.
Reports said the gunmen had entered parliament via a public entrance, dressed as women.
Iranian media later reported that four attackers inside the parliament building had been killed by security forces.
At about 10:40am 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.
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.
Islamic State said it had carried out the attack and later posted a video which showed what it claimed was footage from inside the parliament building.
An Iranian MP later confirmed that the video showed his office and one of his employees lying dead.
This is the most serious terrorist violence in Tehran since the turbulent early years after the 1979 Islamic Revolution.