Iran’s Revolutionary Guards have blamed Saudi Arabia for the first terrorist attack claimed by Islamic State in their country, setting the stage for spiralling tensions between the two rivals at a critical moment in the region.

At least 12 people were killed and dozens more injured in Tehran on Wednesday when gunmen and suicide bombers attacked the Iranian parliament and the mausoleum of the revolutionary founder of the Islamic Republic.

Isis claimed responsibility for the attacks, publishing a brief video that purported to show the assailants inside the parliament.

Reza Seifollhai, the deputy head of Iran’s National Security Council, said on state television that the assailants were Iranian Isis recruits.

“About the identity of the attackers I should say they were from parts of Iran, and had joined Daesh,” Seifollhai said, using the Arabic name for Isis.

But the hardline Revolutionary Guards blamed Riyadh for the attack, in a move that could further raise the stakes in a regional tussle that has already led to major diplomatic upheaval among the Gulf monarchies in recent days and the isolation of Qatar over, in part, its perceived closeness to Iran.

“This terrorist action, coming one week after the meeting of the president of the United States with the leader of the one of the region’s reactionary governments [Saudi Arabia] … shows they are involved in this savage action,” the IRGC said in a statement.

The Iranian president, Hassan Rouhani, said the attacks would make the country more united. “Today’s terrorist attacks in Tehran will make the Islamic Republic of Iran more determined in the fight against regional terrorism, extremism and violence,” he said in a statement published on the ISNA news agency. “We will prove once again that we will crush the enemies’ plots with more unity and more strength.”

The assault on the parliament began when four men armed with rifles burst into the building complex. One of the attackers reportedly blew himself up inside as police surrounded the building.

Gunfire could be heard from outside as police helicopters circled overhead, entrance and exit gates were closed, and contact with mobile phones inside was lost.

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

Members of the Iranian Revolutionary Guards secure the area outside the parliament building. Photograph: Hossein Mersadi/AFP/Getty Images

MPs continued scheduled sessions in another part of the complex. The deputy interior minister, Mohammad Hossein Zolfaghari, told Iran’s state TV that the attackers were dressed as women in order to gain entry.

About five hours after the first reports, Iranian news agencies said all four assailants were dead and the incident was over.

Ali Larijani, the Iranian parliamentary speaker, called the attack a cowardly act. “Iran is an active and effective pillar in the fight against terrorists and they want to damage it,” he said.

Soon after the assault on the parliament began, reports emerged of another incident about 12 miles (19km) south at the mausoleum of Ayatollah Ruhollah Khomeini, who established the Islamic Republic after deposing the shah in 1979.

Two assailants entered the grounds of the shrine, killing a gardener and wounding several other people. One detonated a suicide vest, and the other was shot dead. It was not clear whether the shrine attackers were women, as had been reported earlier, or were just dressed like women.

“The terrorists had explosives strapped to them and suddenly entered the shrine and started to shoot around,” the shrine’s overseer, Mohammadali Ansari, told Reuters.

A Jamaran News image said to be of the moment an attacker detonated a suicide belt at the Khomeini shrine. Photograph: Twitter

Iran’s emergency services said a total of 12 people were killed in the two attacks and 43 wounded. It was not clear whether that toll included the attackers.

The Iranian intelligence ministry said a third team had been arrested before carrying out a planned attack.

Isis released a statement late on Wednesday, threatening Iran’s majority Shia population with more attacks: “The caliphate will not miss a chance to spill their blood”.

Attacks are extremely rare in the capital and other major Iranian cities, although a Sunni militant group named Jundallah and its splinter group, Ansar al-Furqan, have been waging a deadly insurgency, mostly in more remote areas, for almost a decade.

Isis, which adheres to a puritanical strain of Sunni Islam, considers Shias heretics and has carried out numerous attacks against Shia civilians, in Iraq in particular. But this assault, which appeared to have a higher degree of coordination and planning than recent Isis-claimed attacks in Europe, would be a significant escalation.

It took place against a backdrop of great regional tension, with Arab Gulf countries pushing for a more forceful isolation of Iran, their regional arch-enemy. The Gulf states earlier this week severed diplomatic relations with their neighbour Qatarover its close relationship with Tehran.

The US president said: “We grieve and pray for the innocent victims of the terrorist attacks in Iran, and for the Iranian people, who are going through such challenging times. We underscore that states that sponsor terrorism risk falling victim to the evil they promote.”

Last month, Iranian voters re-elected Rouhani, a relatively moderate figure, by a landslide in presidential elections. The high-profile attack on one of the most well-guarded buildings in the capital will come as a blow to the reformist president, who will have to address demands for greater security in the face of the Isis threat.

Isis put out a rare video in Persian in March, warning that it would “conquer Iran and restore it to the Sunni Muslim nation as it was before”, while accusing Iranians of persecuting Sunnis over the centuries.

Charlie Winter, from the International Centre for the Study of Radicalisation at King’s College London, said: “Islamic State has been agitating in Iran for years now but its supporters there haven’t received much attention in the past. In 2016, Isis eulogised seven Iranian suicide attackers that had died in operations in Iraq and Syria.”

Compared with many of its neighbours, he said, Iran was a stable state with “notoriously effective” security services.

“That’s why we’ve not seen an attack there until now. I don’t doubt that the Islamic State has planned operations in Iran in the past – this is just the first one to be a success.”