Terrorists, on Wednesday, attacked two of the most important symbols of Iran’s Islamic government—its well-guarded parliament building and the lavish shrine where the revolutionary leader Ayatollah Ruhollah Khomeini is buried. The basic facts, as reported by Iranian media, followed a familiar pattern: mid-morning, four gunmen penetrated security in the parliament’s Hall of Visitors and opened fire, sparking a dramatic standoff with security forces, which spanned four hours. Government snipers took up positions around the imposing Majlis building and helicopters hovered overhead as people inside tried to drop out of windows to safety. At least one attacker detonated a suicide vest. At Khomeini’s tomb, two people—one a woman—opened fire on pilgrims and then detonated a bomb at the entrance. In the twin attacks, the deadliest in Iran in at least a decade, thirteen people were killed, plus six assailants, and forty-three were injured.

Accounts then quickly diverged over just who was responsible for the terrorist rampage. The Islamic State claimed credit for its first-ever attack in Iran. Soon after the attacks, isis released a twenty-four-second video through its Amaq news agency, which showed a rifle-toting gunman in parliament, standing over a bloodied body. The attacker invoked terms used in isis propaganda about the group’s ability to survive in the Middle East even as it loses its caliphate in neighboring Iraq and Syria. Amid gunshots, the gunman said, “Oh God, thank you. Do you think we will leave? No! We will remain, God willing.” A member of Iran’s parliament later confirmed that the shooting took place in his office and that the dead man was a member of his staff.

Iran’s Revolutionary Guards Corps had a different version, however. It charged that Saudi Arabia and the United States were ultimately to blame, even as it acknowledged the claim by isis. The I.R.G.C. said, in a statement, “Public opinion in the world, especially in Iran, recognizes this terrorist attack—which took place a week after a joint meeting of the U.S. President and the head of one of the region’s backward governments, which constantly supports fundamentalist terrorists—as very significant.” It charged that the isis claim of responsibility “reveals (Saudi Arabia’s) hand in this barbaric action.”

Foad Izadi, a political scientist at the University of Tehran, reflected the thinking in Tehran. “We have the Saudi government financing the mentality of Wahhabism that is the root cause of people going to places and blowing themselves up,” he told Iran’s PressTV. “People don’t do that just for the money. The ideology behind it comes from the Saudi clan.” Wahhabism is the ultra-conservative brand of Islam propagated in the kingdom and in its proselytizing abroad. It has also spawned the extremist ideologies of Osama bin Laden, who was born in Saudi Arabia, and isis.

Either way, the implications are ominous at a time when the energy-rich Gulf is already fraught with unprecedented tensions between its two Islamic powerhouses. Iran, the world’s largest Shiite country, has felt increasingly pressured by Saudi Arabia, the birthplace of Islam and a predominantly Sunni nation. President Trump’s summit last month, in Riyadh, where he mobilized a coalition of conservative Sunni governments to contain Iran, increased tensions. The limited goodwill generated during two years of diplomatic dialogue between Iran and the United States, which resulted in the historic 2015 nuclear agreement, has totally dissipated.

In Washington, the White House issued a statement in the President’s name that laid blame for the attack on Iran’s own “evil” policies. “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,” it said. “We underscore that states that sponsor terrorism risk falling victim to the evil they promote.”

In contrast, the U.N. Security Council passed a resolution within hours condemning “the barbaric and cowardly terrorist attacks” in Tehran and calling for the organizers, perpetrators, and financiers to face justice. The new President of France, Emmanuel Macron, was among the leaders who talked to Iranian President Hassan Rouhani to express condolences. Tehran and Paris pledged to expand coöperation in fighting terrorism.

In angry language, the Revolutionary Guards vowed to respond to the attacks, implicitly including Saudi Arabia. “We will remain steadfast in fighting terrorists and we will surely take revenge on terrorists, their affiliates and their supporters,” Brigadier General Hossein Salami, the I.R.G.C. second-in-command, said.

Just as ominous, however, is the new confrontation between Iran and the Islamic State. During the isis sweep into Iraq, in 2014, the caliphate’s fighters came within twenty-five miles of Iran’s borders. Iran was then the first country to fly in aid and military advisers to help Iraq’s northern Kurds fight isis. For Iran, holding off invasions by Sunni hordes has been its primary regional security concern for half a millennium. The Islamic Republic and the Islamic State also have rival visions of the ideal Islamic government. Iran is a modern republic with a constitution based on French and Belgian law, with Islamic tenets added in parallel institutions. Its culture—including the role of women—is dynamic. In contrast, isis advocates returning to the political rule and societal mores of the seventh century, when Islam was founded.

But Tehran has not been in the Islamic State’s immediate crosshairs until recently. This spring, isis began to translate its slick monthly online publication Rumiyah (Arabic for “Rome”) into Farsi, Iran’s main language. It also released a forty-minute video in Farsi calling for Sunnis in Iran to rebel against the regime—and to take the country back to its Sunni roots. In the sixteenth century, the dynasty formally changed Iran’s national religion from Sunni to Shiite Islam as a means of crafting a separate identity to prevent the expanding Ottoman Empire from absorbing Persia. The recent video also faulted Iran for allowing Jews to maintain and worship in synagogues, even as, according to the video, it persecuted and killed its restive minority Sunnis.

Less than ten per cent of Iran’s eighty-one million people today are Sunni. All of the assailants were Iranian nationals, police said. Iran arrested five people after the attacks, although it provided no details on their identities.

Tehran tried to downplay the long-term danger. “Iranian nation moves on, today the fumbling with firecrackers in #Tehran, won’t affect the will of our nation,” Ayatollah Ali Khamenei, the nation’s supreme leader, tweeted on his English-language account. After the recent attack, the speaker of parliament, Ali Larijani, said that the attacks were only a “minor incident” by “some cowardly terrorists.”

The regime was clearly trying to calm a nation unsettled by the kind of attacks it has not experienced since the years just after the 1979 revolution. In 1981, an opposition group bombed the headquarters of the ruling Islamic Republican Party. More than seventy top politicians, including twenty-seven members of parliament, four cabinet ministers, and the chief justice of Iran’s supreme court were killed. Almost four decades later, the dual attacks on Wednesday unsettled Iranians. It was just the latest of the region’s proliferating crises.