A gunman shot dead a security guard and wounded two other people at Azerbaijan's embassy in Iran on Friday, in an attack Baku branded an "act of terrorism" that it said was the result of Tehran failing to heed its calls for improved security.
Police in Tehran said they had arrested a suspect and Iranian authorities condemned the incident, but said the gunman appeared to have had a personal, not a political motive.
The incident comes amid increased tensions between the two neighboring countries over Iran's treatment of its large ethnic Azeri minority and over Azerbaijan's decision this month to appoint its first ever ambassador to Israel.
"The attacker broke through the guard post, killing the head of security with a Kalashnikov assault rifle," Azerbaijan's foreign ministry said.
CCTV footage obtained by Reuters showed the attacker forcing his way into the building and shooting at two men before a third embassy employee grapples him away.
Reasons for the attack
A grey-haired man identified as the attacker was later shown on Iranian state TV saying he had acted to secure the release of his Azeri wife who he believed was being held at the embassy.
A young woman identified as the man's daughter said her mother was in Azerbaijan. "My mother is not in the embassy and I told him that but he did not accept that," she said.
Iran's President Ebrahim Raisi called for "a comprehensive investigation" of the incident and sent his condolences to Azerbaijan and the dead man's family, Iranian state media said.
Iranian Foreign Minister Hossein Amirabdollahian, quoted on a government site, said that based on evidence and initial observations the gunman's motive was "completely personal."
"Necessary security measures have been taken to continue normal activities at the embassy and diplomats of the Republic of Azerbaijan in Tehran," he said.
Azerbaijan's foreign ministry responded strongly to the attack, summoning Iran's ambassador in Baku to demand justice and saying it would evacuate its embassy staff from Tehran.
It said an "anti-Azerbaijani campaign" in Iran had contributed to the attack, without elaborating, and accused Tehran of long ignoring its appeals to boost embassy security.
"Unfortunately, the latest bloody terrorist act demonstrates the serious consequences of the failure to give the necessary attention to our constant appeals in this regard," it said.
Iran's Amirabdollahian later told Azeri Foreign Minister Jayran Bairamov in a phone call that he hoped the attack would not damage bilateral ties.
Azerbaijan's President Ilham Aliyev demanded swift punishment for those involved in Friday's "act of terrorism."
Aliyev has complained in the past about Iran's treatment of its Azerbaijani minority, saying for example that Azeris have no schools where they can study in their own language.
Azerbaijan, a secular Muslim former Soviet republic, has friendly ties with the United States and Israel and has had difficult diplomatic relations with Iran.
Azerbaijan appointed its first ever ambassador to Israel this month. Israel has had an embassy in Baku since the early 1990s and has been a significant military backer of Azerbaijan in recent years. It has also provided diplomatic support for Baku in its standoff with Armenia over the disputed Nagorno-Karabakh region.
Iran's Revolutionary Guards carried out major military drills along the country’s borders with Armenia and Azerbaijan amid fears of renewed fighting between the two South Caucasus states last year.