ISIS claimed responsibility Wednesday for a pair of stunning attacks on Iran's parliament and the tomb of its revolutionary leader, Ayatollah Ruhollah Khomeini, which killed at least 12 people and wounded more than 40.

Tehran police Chief Gen. Hossein Sajedinia announced late Wednesday night that five suspects had been detained for interrogation, according to a report in the semi-official ISNA news agency. Sajedinia did not offer any further details.

Reza Seifollahi, an official with the country's Supreme National Security Council, was quoted by the independent Shargh daily as saying that the perpetrators of the attacks were Iranian nationals. He did not elaborate.

The bloodshed shocked the country and came as emboldened Sunni Arab states — backed by U.S. President Donald Trump — are hardening their stance against Shia-ruled Iran.

Women are seen inside the parliament building during an attack in central Tehran, Iran, on Wednesday. (TIMA via Reuters)

In recent years, Tehran has been heavily involved in conflicts in Syria and Iraq against the militant group, but had remained untouched by ISIS violence. Iran has also battled Saudi-backed Sunni groups in both countries.

Iran's powerful Revolutionary Guard indirectly blamed Saudi Arabia for the attacks. A statement issued Wednesday evening stopped short of alleging direct Saudi involvement but called it "meaningful" that the attacks followed Trump's visit to Saudi Arabia, where he strongly asserted Washington's support for Riyadh.

The statement said Saudi Arabia "constantly supports" terrorists including ISIS, adding that the group's claim of responsibility "reveals [Saudi Arabia's] hand in this barbaric action."

The "spilled blood of the innocent will not remain unavenged," the Revolutionary Guard statement said.

Ayatollah Ali Khamenei, the country's supreme leader, used the attacks to defend Tehran's involvement in wars abroad. He told a group of students that if "Iran had not resisted," it would have faced even more troubles.

"The Iranian nation will go forward," he added.

Supreme Leader Ayatollah Ali Khamenei addresses a group of students in Tehran on Wednesday. Khamenei used the attacks to defend Tehran's involvement in wars abroad, telling the students that if 'Iran had not resisted,' it would have faced even more troubles. (Office of the Iranian Supreme Leader via Associated Press)

The violence began midmorning when assailants with Kalashnikov rifles and explosives stormed the parliament complex where a legislative session was in progress. The siege lasted for hours, and one of the attackers blew himself up inside, according to Iran's state TV.

Images circulating in Iranian media showed gunmen who held rifles near the windows of the complex. One showed a toddler being handed through a first-floor window to safety outside as an armed man looks on.

ISIS's Aamaq news agency released a 24-second video purportedly shot inside the complex, showing a bloody, lifeless body on the floor next to a desk.

An Associated Press reporter saw several police snipers on the roofs of nearby buildings. Police helicopters circled the parliament and all mobile phone lines from inside were disconnected.

Shops in the area were closed as gunfire rang out and officials urged people to avoid public transportation. Witnesses said the attackers fired from the parliament building's fourth floor at people in the streets.

"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, told the AP. "With the help of a taxi driver, I reached a nearby alley."

As the parliament attack unfolded, gunmen and suicide bombers also struck outside Khomeini's mausoleum on Tehran's southern outskirts. Khomeini led the 1979 Islamic Revolution that toppled the Western-backed shah to become Iran's first supreme leader until his death in 1989.

Iran's state broadcaster said a security guard was killed at the tomb and that one of the attackers was slain by security guards. A woman was also arrested. The revered shrine was not damaged.

The Interior Ministry said six assailants were killed — four at the parliament complex and two at the tomb. A senior Interior Ministry official told Iran's state TV the male attackers wore women's attire.

The mausoleum of the founder of the Islamic Republic Ayatollah Ruhollah Khomeini was attacked Wednedsday. (TIMA via Reuters)

Parliament Speaker Ali Larijani called the attacks cowardly.

Canada responds

Chrystia Freeland, minister of foreign affairs, issued a statement on the attacks Wednesday.

"Canada strongly condemns today's terrorist attacks in Iran, including at their parliament," Freeland said in the statement.

"We grieve the deaths and the injuries sustained by many civilians and deplore the targeting of innocent Iranians. Our thoughts and sympathies are with the people of Iran."

Saudi Arabia and Iran regularly accuse each other of supporting extremists in the region. Saudi Arabia has long pointed to the absence of ISIS attacks in Iran as a sign of Tehran's culpability. For its part, Iran has cited Saudi Arabia's support for jihadists and its backing of hardline Sunni fighters in Syria.

Trump's first overseas visit to Saudi Arabia last month positioned the U.S. firmly on the side of the kingdom and other Arab states in their stance against Iran. His assurances of Washington's support emboldened hawkish royals in Saudi Arabia, which is at war in Yemen against Iranian-allied rebels.

The attacks are likely to deepen enmity and sharpen the regional battle for power between the two rivals. Tensions are running high this week following a cut in ties between key Arab powers and Qatar over accusations that the energy-rich nation supports terrorist groups and is aligning itself too closely with Iran.

A young boy is removed from the Iranian parliament complex in Tehran during the attack. (Omid Vahabzadeh/Tima via Reuters)

Saudi Arabia has been a target of numerous lethal attacks by ISIS affiliates who see the kingdom's Western-allied leadership as heretics. The group has also targeted Shia in Saudi Arabia and Kuwait.

ISIS militants are fighting Iranian-backed forces in Syria and Iraq, and they view Shia as apostates. Iran shares borders with Iraq and Turkey, where extremists could have slipped in.

Nelly Lahoud, an expert on extremism at the International Institute for Strategic Studies in Bahrain, said ISIS leaders may be looking to rally supporters through the attacks in Iran as they lose ground in Syria and Iraq.

"Now that they are unable to maintain the promise of territory, attacking Iran is to their advantage," she said. "It wouldn't surprise me if this were planned for a long time."

On March 27, ISIS posted a 37-minute video in Farsi threatening Iran. The Clarion Project said the speakers claimed to represent various Iranian Sunni ethnic groups, such as the Baluchis and Ahvazis, and encouraged Iranian Sunnis to join the group.

Members of Iranian security forces during the attack in central Tehran. (Omid Vahabzadeh/Tima via Reuters)

Wednesday's attacks, during the holy month of Ramadan that is observed by both Sunni and Shia Muslims, came as ISIS is competing with al-Qaeda for jihadi recruits.

Arab separatists are active in Iran's southern city of Ahvaz, where they killed two policemen three weeks ago. Though most Iranians are Shia, including separatists in Ahvaz, the eastern Baloch region is majority Sunni, although there are no recent census figures available. There is also a significant Sunni population in southern Hormozgan province.

UN, U.S. condemn attacks

The attacks drew condemnation from Iran's allies — and also from the U.S. That was notable because of the deep distrust between Tehran and Washington, which don't have diplomatic relations.

State Department spokesperson Heather Nauert said the U.S. expressed condolences to the victims and their families.

"The depravity of terrorism has no place in a peaceful, civilized world," Nauert said.

Russian President Vladimir Putin sent condolences and confirmed Moscow's willingness to aid its ally. Syria's foreign ministry also condemned the attacks, which it said were backed by various governments that it did not specify.

People gather near the parliament building during the attack. (Tima via Reuters)

The United Nations Security Council also condemned the attacks, saying "terrorism in all its forms and manifestations constitutes one of the most serious threats to international peace and security" and that "any acts of terrorism are criminal and unjustifiable."

The Islamic State group often claims attacks around the world, even when links to the group cannot be confirmed. Iranian security officials have not said who might have been behind the attacks, although state media called the assailants "terrorists."

There are concerns that a doubling down on security could lead to a wider clampdown on the opposition in Iran. Rights group Amnesty International urged Iranian authorities to carry out impartial investigations into the attacks.

Charlie Winter, a senior research fellow at King's College London, said the attacks could provoke a disproportionate counterterrorism response in Iran.

"Iranian officials will be called upon to step up intervention in Iraq [and] Syria big time," he said, adding that Wednesday's attacks will significantly boost ISIS morale amid battlefield defeats.