In the 10 days since the United States killed Iran's most powerful military commander in a drone strike, Tehran has faced escalating confrontation with the West and unrest at home, both reaching levels with little precedent in its modern history.
It shot down the airliner on Wednesday during a period of high alert, hours after it had fired missiles at U.S. targets in Iraq. After days of denying a role in the crash, it admitted it on Saturday, calling it a tragic mistake.
Protesters, many of them students, have since held daily demonstrations chanting "Clerics get lost!" and called for the removal of Supreme Leader Ayatollah Ali Khamenei, in power for more than 30 years.
Police have responded to some protests with a violent crackdown, video posts on social media showed. Footage showed police beating protesters with batons, wounded people being carried, pools of blood on the streets and the sound of gunfire.
Iran's police denied firing at protesters. The judiciary said 30 people had been detained in the unrest but said the authorities would show tolerance towards "legal protests".
The full extent of the unrest is difficult to assess because of limits on independent reporting.
President Hassan Rouhani promised a thorough investigation into the "unforgivable error" of shooting down the plane, in a television address on Tuesday, the latest in a series of apologies from a leadership that rarely admits mistakes.
Judiciary spokesman Gholamhossein Esmaili said some of those accused of having a role in the plane disaster had been arrested, although he did not say how many or identify them.
Most of those on board the flight were Iranians or dual nationals. Canada, Ukraine, Britain and other nations who had citizens on the plane have scheduled a meeting on Thursday in London to consider legal action against Tehran.
The disaster and subsequent unrest comes amid one of the biggest escalations between Tehran and Washington since 1979.
Missiles launched at a U.S. base in Iraq killed an American contractor in December, an attack Washington blamed on an Iran-backed group. Confrontation eventually led to the U.S. drone strike on Jan. 3 that killed Qassem Soleimani, architect of Iran's regional network of proxy militias.
Iran's government was already reeling from the reimposition of sanctions by the United States, which quit an agreement with world powers under which Tehran would secure sanctions relief in return for scaling back its nuclear programme.
Since Washington withdrew, Tehran has stepped back from its nuclear commitments, culminating this month with an announcement that Iran would no longer recognise limits on its production of enriched uranium. After months of threatening to act, European signatories to the deal, France, Britain and Germany, activited the agreement's dispute mechanism on Tuesday.
Iran's leaders face a powerful combination of pressure both at home and abroad.
Just two months ago, Iran's authorities put down anti-government protests, killing hundreds of demonstrators in what is believed to be the most violent crackdown on unrest since the 1979 revolution.
Elsewhere in the Middle East, where Iran has wielded influence through a network of allied movements and proxies. Governments that include powerful Iran-sponsored armed factions have faced months of hostile demonstrations in Lebanon and Iraq.
The latest video posts on social media showed protesters in Tehran and other cities. Some tore down or burned posters of Soleimani, a man portrayed for years as a national hero.
Iran's president said in his address that those responsible for shooting down the plane would be punished, describing the military's admission of its mistake "a good first step."
Rouhani also said the government would be accountable to Iranians and those nations who lost citizens.
Ukrainian Foreign Minister Vadym Prystaiko said five of the nations whose citizens were killed in the plane disaster would meet in London on Thursday "to discuss the ways, including legal, (for) how we are following this up."
Iranian state television said aviation officials from Canada, which had 57 citizens on the doomed flight, as well as from Iran and Ukraine met in Tehran on Tuesday to discuss the investigation.
(Reporting by Parisa Hafezi and Babak Dehghanpisheh and John Irish in Paris Writing by Edmund Blair Editing by Peter Graff) ((firstname.lastname@example.org; Reuters Messaging: email@example.com))