Iran’s clerical rulers have faced nationwide demonstrations since the death in police custody of Mahsa Amini, a 22-year-old Kurdish woman, on 16 September.
Iranians have called for the death of Khamenei and an end to the Islamic Republic during the protests, which have become one of the boldest challenges to the clerical leadership since the 1979 revolution, drawing many Iranians on to the streets.
Officials said they had arrested a gunman who carried out the attack at the Shah Cheragh shrine in the city of Shiraz. State media blamed “takfiri terrorists” - a label that predominantly Shi’ite Iran uses for hardline Sunni Muslim militants such as Islamic State.
A senior official said the suspected attacker was in critical condition after being shot by police.
“We have not been able to interrogate him yet,” said deputy provincial governor Easmail Mohebipour, quoted by the semi-official Tasnim news agency.
CCTV footage broadcast on state TV on Thursday showed the attacker entering the shrine after hiding an assault rifle in a bag and shooting as worshippers tried to flee and hide in corridors.
Islamic State, which once posed a security threat across the Middle East, has claimed previous violence in Iran, including deadly twin attacks in 2017 that targeted parliament and the tomb of the Islamic Republic’s founder, Ayatollah Ruhollah Khomeini.
Since the peak of its power, when it ruled millions of people in the Middle East and struck fear across the world with deadly bombings and shootings, Islamic State has slipped back into the shadows.
Iran often accuses the West and its regional rivals Israel and Saudi Arabia of fomenting attacks. Saudi Arabia denies this and Israel usually declines to comment on its moves against the Islamic Republic.
Wednesday’s killing of Shi’ite pilgrims came on the same day that Iranian security forces clashed with increasingly strident protesters marking 40 days since Amini’s death.
Iranian leaders may have hoped that the shrine attack would draw attention away from the unrest but there is no sign that is happening.
The official news agency IRNA said protesters angry over the “suspect” death of a demonstrator broke windows of banks, a tax office and other public buildings in the northwestern city of Mahabad.
The Kurdish human rights group Hengaw said security forces killed at least five people during protests on Thursday in the northwest of the country, where many Kurds live. Three were killed in the city of Mahabad and another two in Baneh, it said.
State television confirmed the death of three people in Mahabad, saying they died after protesters attempted to occupy government and security centres. It showed footage of a burning building that was surrounded by demonstrators.
Separately, state media said two Basij militiamen were killed in an attack in the northern city of Amol, which has been a hotbed of protests. Tasnim news agency said a member of the elite Revolutionary Guards had been killed in Tehran province by “rioters” using a hand grenade.
Iranian human rights groups said there were unconfirmed reports that some members of Amini’s family were under house arrest. Reuters could not verify these reports. Reuters tried to reach Amini’s father and brother.
The authorities, who have accused the United States and other Western countries of fomenting what they call “riots”, have yet to declare a death toll, but state media have said about 30 members of the security forces have been killed.
The activist news agency HRANA said in a posting that at least 252 protesters had been killed in the unrest, including 36 minors. It said more than 13,800 people had been arrested in protests in 122 cities and towns and some 109 universities.