Suicide bombers and gunmen attacked Iran's parliament and the Mausoleum of Ayatollah Khomeini in Tehran on Wednesday morning, killing at least 12 people in a twin assault at the heart of the Islamic Republic, Iranian officials and media said.

>> ISIS assault on Tehran may lead to surprising alliances in the Middle East | Analysis

Islamic State claimed responsibility and released a video purporting to show gunmen inside the parliament building and one body, apparently dead, on the floor.

The rare attacks were the first claimed by the hardline Sunni Muslim militant group inside in the tightly controlled Shi'ite Muslim country. Islamic State has regularly threatened Iran, one of the powers leading the fight against the militants' forces in neighboring Iraq and, beyond that, Syria.

The raids took place at a particularly charged time after Iran's main regional rival Saudi Arabia and other Sunni powers cut ties with Qatar on Monday, accusing it of backing Tehran and militant groups.

Open gallery view A map showing the sites of the Tehran attacks Credit: Haaretz

Open gallery view An Iranian policeman looks out of the parliament's building in central Tehran, Iran, June 7, 2017. Credit: Omid Vahabzadeh/AP

The incident could exacerbate tensions in Iran between newly re-elected President Hassan Rohani, a pragmatist, and his rivals among hardline clerics and the powerful Islamic Revolutionary Guard Corps (IRGC).

>> Iran creating new Middle East reality, Striving for Land Corridor From Tehran to Beirut >> WATCH: Saudi ban pushes Qatar flights to Africa through Europe

Attackers dressed as women burst through parliament's main entrance in central Tehran, deputy interior minister Mohammad Hossein Zolfaghari said, according to the semi-official Tasnim news agency.

One of them detonated a suicide vest in the parliament, he said. About five hours after the first reports, Iranian media said four people who had attacked parliament were dead and the incident was over.

At least 12 people were killed by the attackers, the head of Iran's emergency department, Pir-Hossein Kolivand, was quoted as saying by state broadcaster IRIB.

Open gallery view Members of Iranian forces run to the Iranian parliament building in Tehran, June 7, 2017. Credit: TIMA AGENCY/REUTERS

"I was inside the parliament when shooting happened. Everyone was shocked and scared. I saw two men shooting randomly," said one journalist at the scene, who asked not to be named.

Open gallery view Iranian police stand near the parliament's building during a gunmen attack in central Tehran, Iran, June 7, 2017. Credit: TIMA AGENCY/REUTERS

Soon after the assault on parliament, another bomber detonated a suicide vest near the shrine of the Republic's revered founder, Ayatollah Khomeini, a few kilometers (miles) south of the city, Zolfaghari said, according to Tasnim.

A second attacker was shot dead, he said. The shrine is a main destination for tourists and religious pilgrims.

"The terrorists had explosives strapped to them and suddenly entered the shrine and started to shoot around," said the shrine's overseer, Mohammadali Ansari.

The Intelligence Ministry said security forces had arrested another "terrorist team" planning a third attack, without giving further details.

"I was shopping and suddenly heard shooting," said housewife Maryam Saghari, 36, who lives near parliament. "People started to run away from the area. I was very scared. I don't want to live in fear," she told Reuters by telephone.

Television footage showed police helicopters circling over the parliament building, with snipers on its rooftop. Tasnim praised the elite Revolutionary Guards for confronting the attackers.

Iran's Revolutionary Guard Corps blamed Saudi Arabia for the attacks in an official statement. The Fars news agency, which is close to the Guards, blamed Iran's arch foes, the United States and Saudi Arabia, for the attacks. It noted that they took place two weeks after U.S. President Donald Trump visited Riyadh and vowed to isolate Iran.

Iran is locked in a tussle with Saudi Arabia for regional influence which is being played out in the Yemen conflict as well as in Syria and Iraq.

Sunni insurgency

The raids on two of Iran's most highly-protected sites will jolt Rouhani, who positions himself as a reformer, and his political rivals among the hardline clerics and the Revolutionary Guards, who are responsible for national security.

In an appeal for unity, Rohani's chief of staff, Hamid Aboutalebi, took to Twitter to praise the security services.

"If this attacks had happened in any other city in Europe or in the world, it would have left many casualties. Applause to the power and firmness of our revolutionary guards, Basij, police and security forces," he wrote.

Two senior government officials, who asked not to be named, said the blasts might prompt a blame game and exacerbate political in-fighting.

"They (hardliners) are very angry and will use every opportunity to grow in strength to isolate Rohani," said one of the officials.

The other said the attacks, and speculation over who backed them, would push Iran toward "a harsher regional policy."

The Intelligence Ministry called on people to be vigilant and report any suspicious movement.

"Some cowardly terrorists infiltrated one of the buildings of parliament. They were confronted. It was not a major issue. Our security forces have taken necessary steps," parliament speaker Ali Larijani said in a session broadcast live by state TV.

Attacks are rare in Tehran and other major cities though two Sunni militant groups, Jaish al-Adl and Jundallah, have been waging a deadly insurgency, mostly in more remote areas, for almost a decade.

Iran's restive Sistan and Baluchestan province, in the southeast on the borders with Pakistan and Afghanistan, is home to the Balouch minority and has long been a hotbed of Sunni insurgents fighting the Shi'ite-led Islamic Republic.

Last year Iranian authorities said they had foiled a plot by Sunni militants to bomb targets in Tehran and other cities during the Muslim holy month of Ramadan.

Iranian Foreign Minister Mohammad Javad Zarif, who is visiting Turkey to discuss the Qatar crisis, told reporters that the attacks will "strengthen resolve of the Iranian nation against terrorism."

Islamic State has lambasted "heretic" Shi'ite Iran for helping the Syrian and Iraqi governments battle Islamic State, which considers Shi'ites to be infidels.

The video released by Islamic State's news agency Amaq included an audio track of a man saying: "Oh God, thank you. . Do you think we will leave? No! We will remain, God willing."