Gunmen and suicide bombers stormed Iran’s parliament and the shrine of its revolutionary leader on Wednesday, killing 12 people and injuring 39 in the first attacks in the country claimed by the Islamic State group.

The attacks ended after a standoff lasting several hours, during which the gunmen holed up in parliamentary office buildings.

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.

Get The Times of Israel's Daily Edition by email and never miss our top stories Free Sign Up

A voice on the video praises God and says in Arabic: “Do you think we will leave? We will remain, God willing.” Another voice repeats the same words. The two appeared to be parroting a slogan used by IS spokesman Abu Mohammad al-Adnani, who was killed in Syria last year.

ISIS releases video filmed by one of their militants inside #Iran parliament. Can someone recognize accent of the fighter? pic.twitter.com/Qe351ZjMnM — Wladimir (@vvanwilgenburg) June 7, 2017

Police said all the attackers had been killed by around 3 p.m. (10:30 GMT), some five hours after the attack started.

The Sunni jihadists of IS consider Shiite Iran to be apostate, and Tehran is deeply involved in fighting the group in both Syria and Iraq.

The assaults began mid-morning, when four gunmen burst into the parliament complex in the center of Tehran, killing a security guard and one other person, according to the ISNA news agency.

Another video of the Parliament, intense shooting can be heard #Iran pic.twitter.com/GDrd5z130k — Michael Horowitz (@michaelh992) June 7, 2017

An interior ministry official said they were dressed as women and entered through the visitors’ entrance.

At roughly the same time, a team of three or four assailants entered the grounds of the mausoleum of Ayatollah Ruhollah Khomeini, who led the 1979 Islamic revolution, killing a gardener and wounding several other people.

Iran’s emergency services said a total of 12 people were killed in the two attacks and 39 were wounded.

Two of the attackers at the shrine, one of them a woman, blew themselves up, while another detonated a suicide vest on the fourth floor of the parliamentary office building.

#BREAKING#Iran shooting

Moment of explosion on western wing outside Imam Khomeini shrine. pic.twitter.com/4U0OCYyEel — Mehr News Agency (@MehrnewsCom) June 7, 2017

A picture on social media showed police helping staff escape through windows.

Large crowds gathered around cordons to watch as police struggled to disperse the crowds.

Parliament was in session as the attacks unfolded and members were keen to show they were undeterred, continuing with regular business.

Some posted selfies of themselves looking calm, even as gun battles raged in surrounding office buildings and snipers took position on nearby rooftops.

The speaker of Iran’s parliament described Wednesday’s terror attack as a “minor incident,” the Iranian Mehr news agency reported.

Ali Larijani chaired business-as-usual proceedings within the parliamentary chamber while gunfights went on elsewhere in the building.

He described Iran as an “active and effective hub for combating terrorism” and said terrorists wanted to undermine this.

As he spoke, some lawmakers shouted, “Death to America.”

State news channels said parliament had gone back to work shortly after the first reports of gunfire, while other channels avoided reporting on the attack altogether.

An official at Khomeini’s mausoleum in south Tehran said “three or four” people had entered via the western entrance and opened fire, according to the Fars news agency.

The intelligence ministry said there had been a third “terrorist” team that was neutralized before the attacks started.

The city was on lockdown for several hours, with streets blocked and parts of the metro closed. Journalists were kept away from the shrine by police.

Latest on #Tehran: Iranian security forces have surrounded parliamentary building where gunmen might be holding hostages. pic.twitter.com/vZIQC8keYh — Rudaw English (@RudawEnglish) June 7, 2017

“I was passing by one of the streets. I thought that children were playing with fireworks, but I realized people are hiding and lying down on the streets,” Ebrahim Ghanimi, who was around the parliament building when the assailants stormed in, told The Associated Press. “With the help of a taxi driver, I reached a nearby alley.”

Police helicopters circled over the parliament building and all mobile phone lines from inside were disconnected. The semi-official ISNA news agency said all entrance and exit gates at parliament were closed and that lawmakers and reporters were ordered to remain in place inside the chamber.

Interior Minister Abdolrahman Fazli told ISNA he had convened a special meeting of the country’s security council.

Jihadist groups have clashed frequently with security forces along Iran’s borders with Iraq and Afghanistan, but the country has largely escaped attacks within its urban centers.

The intelligence ministry said in June 2016 that it had foiled a plot to carry out multiple bomb attacks in Tehran and around the country.

IS 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.”

Iran, the predominant Shiite power, has been helping both Iraq and President Bashar Assad’s regime in Syria to battle IS.

The jihadist group is under increasing pressure in both countries, having lost significant territory in the face of offensives now targeting its last two major urban bastions, Raqa in Syria and Mosul in Iraq.

Militant groups are also known to operate in Iran’s southeastern Sistan-Baluchistan province, which borders Pakistan and has a large Sunni community.

Jaish-ul Adl (Army of Justice), which Tehran accuses of links with al-Qaeda, has carried out several armed attacks on Iranian soil in recent years.

The Kremlin, which has been fighting IS in Syria and Iraq together with Iran and Syria’s Assad, condemned the attacks in Tehran and called for greater coordination in the fight against the group.

“Moscow decisively condemns such terrorist attacks,” Kremlin spokesman Dmitry Peskov said, adding that “the continuation of a series of terror attacks again underlines the need for coordinated actions in the fight against terror and IS.”

United Arab Emirates also condemned the attacks.

“Our position on terrorism is very clear… Any terrorist attack in any country, in any capital, directed at innocent people is something that the UAE abhors and the UAE condemns,” state minister for foreign affairs Anwar Gargash told AFP.

The European Unions high representative for foreign affairs and security policy, Federica Mogherini, sent her condolences to the victims of the Tehran attacks and said she was following events very closely on this “very sad day again.”