Isis (Islamic State) has struck at Iran and its allies for years - but always from afar, in places such as Iraq against Tehran-backed militias and in Syria battling government troops aided by Iranian forces.
That appeared to change when bloodshed came to Tehran on Wednesday. In a few chaotic hours, Iran endured the kind of deadly rampages so often claimed by Isis elsewhere.
The twin attacks, the first major assaults in Iran claimed by Isis, targeted both the heart of Iran's political identity and the notion that militants were no match for the security forces zealously guarding Tehran.
At least 12 people were reported killed and 42 wounded in the assaults in the Parliament building and outside the tomb of the leader of the nation's Islamic revolution.
Security forces eventually killed all four assailants, state media reported. Hours later, Tehran's police chief said five suspects had been detained and were being interrogated.
While the attacks showed that the United States and Iran have a shared enemy, they appeared unlikely to reset US-led efforts against Isis or bring Iran more directly into the fight - especially since the Trump Administration has embraced Iran's main regional foe, Saudi Arabia, as a bulwark in fighting Islamist militants and constraining Iran's regional influence.
In a White House statement, President Donald Trump: "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."
The Washington-based National Iranian American Council promptly rebuked what it called Trump's "heartless message", saying that presidents who "cannot genuinely recognise victims of terrorism are incapable of leading the fight against terror".
Iran's powerful Revolutionary Guard Corps took a thinly veiled jab at Saudi Arabia as a source of militant ideology, saying it was "meaningful" that the attacks occurred less than three weeks after Trump visited Riyadh and asserted strong US support for the Saudis and their allies.
The Revolutionary Guard statement added that the "spilled blood of the innocent will not remain unavenged". Iran is predominantly Shia Muslim and is at odds with Sunni extremist groups such as al-Qaeda and Isis, which view Shia as heretics and have attacked Shia targets across the region.
While it is unclear what direct measures Iran could take against Isis, the fallout is certain to deepen regional tensions at a difficult time. Saudi Arabia and its allies have severed ties with Qatar, a key US military partner in the Persian Gulf.
The Saudis and their allies accuse Qatar of supporting Islamist militants and oppose its outreach to Iran.
For Isis, striking directly at Iran appears to be part of a wider attempt to stir regional discord.
An attack inside Iran was "absolutely the realisation of a long-term ideological goal" for Isis, said Charlie Winter, a senior research fellow at the International Centre for the Study of Radicalisation at King's College in London. "Ideologically, the implications are huge," he said. "Attacking Iran is kind of like attacking the US or Israel."
The near-simultaneous attacks - coming in the middle of the Islamic holy month of Ramadan - also appeared calculated to elicit maximum shock among Iranians.
Parliament is widely respected as a voice on domestic policies even though Iran's supreme leader, Ayatollah Ali Khamenei, has the final word on most international and security issues.
The shrine of Khamenei's predecessor, Ayatollah Ruhollah Khomeini, is a centrepiece of homage to the 1979 Islamic revolution, which overthrew Iran's Western-allied monarchy.
The timing, meanwhile, could have been intended to boost Isis' stature among backers as it faces a two-pronged assault against its key urban strongholds: Mosul in northern Iraq and Raqqa in Syria.
An expanded offensive by US-backed forces against Raqqa, Isis' de facto capital, began on Wednesday.
"It is indeed a boost to Isis morale, especially given that it's the first successful attack in Iran," said Dina Esfandiary, who studies global security issues at the Centre for Science and Security Studies at King's College.
However, Iranian state TV quoted Khamenei as dismissing the attacks as mere "fireworks" that would not weaken Iran's fight against groups such as Isis.