A man armed with a Kalashnikov-style rifle stormed the Azerbaijan embassy in Iran’s capital, killing the head of security at the diplomatic post and wounding two guards, authorities have said.
Tehran’s police chief, General Hossein Rahimi, blamed the attack on “personal and family problems”, according to Iranian state television.
However, the assault comes as tensions have been high for months between neighbouring Azerbaijan and Iran.
Azerbaijan’s Foreign Ministry said it would evacuate its diplomatic mission, accusing Iran of not taking reported threats against it seriously in the past.
Meanwhile, Iranian authorities replaced Gen Rahimi as police chief hours later after footage emerged that appeared to show a police officer doing nothing to stop the attack.
Video purportedly from the scene of the attack showed an empty diplomatic police post near the embassy, with one man apparently wounded in an SUV parked outside.
Inside the embassy past a metal detector, paramedics stood over what appeared to be a lifeless body in a small office as blood pooled on the floor beneath.
A statement from Azerbaijan’s Foreign Ministry said that “an investigation is currently under way into this treacherous attack”.
The ministry also described the attacker as destroying a guard post with assault rifle fire before being stopped by the wounded guards, whom authorities described as being in a “satisfactory” condition after being shot.
However, the ministry said a “recent anti-Azerbaijani campaign against our country in Iran has encouraged such attacks against our diplomatic mission”.
“There have been attempts to threaten our diplomatic mission in Iran before, and measures to prevent such situations and to ensure the safety of our diplomatic missions have been constantly raised before Iran,” the ministry said.
“Unfortunately, the last bloody terrorist attack demonstrates the serious consequences of not showing proper sensitivity to our urgent appeals in this direction.”
Azerbaijan President Ilham Aliyev called the attack a “terrorist act”.
“A terrorist attack against diplomatic missions is unacceptable!” he said in a statement.
Iranian state TV had quoted Gen Rahimi as saying the gunman had entered the embassy with his two children during the attack.
However, surveillance footage from inside the embassy released in Azerbaijan, which matched details of the other video of the aftermath and bore a timestamp matching the Azerbaijan Foreign Ministry’s statement, showed the gunman burst through the embassy’s doors alone.
Those inside tried to push through metal detectors to take cover.
The man opens fire with the rifle, its muzzle flashing, as he chases after the men into the small side office.
Another man bursts from a side door and fights the gunman for the rifle as the footage ends.
Another surveillance video from outside the embassy which also corresponded to the same details showed the gunman slam his car into another in front of the embassy.
The gunman then got out and levelled his rifle at a figure inside the Iranian police stand, probably a police guard, who stood still and did nothing as the man stormed the embassy.
Associated Press journalists saw the embassy’s front door pocked with bullet holes after the attack.
Iranian prosecutor Mohammad Shahriari reportedly said that the gunman’s wife had disappeared in April after a visit to the embassy.
The Iranian judiciary’s Mizan news agency quoted Mr Shahriari as saying the gunman believed his wife was still in the embassy at the time of the attack – even though it was some eight months later.
Iran’s Foreign Ministry spokesman Nasser Kanaani also said his country strongly condemned the attack, which was under investigation with “high priority and sensitivity”.
Azerbaijan borders Iran’s north-west.
There have been tensions between the two countries as Azerbaijan and Armenia have fought over the Nagorno-Karabakh region.
Iran in October launched a military exercise near the Azerbaijan border, flexing its martial might amid the nationwide protests rocking the Islamic Republic.
Azerbaijan also maintains close ties to Israel, which Tehran views as its top regional enemy.
The Islamic Republic and Israel are locked in an ongoing shadow war as Iran’s nuclear programme rapidly enriches uranium closer than ever to weapons-grade levels.
Turkey, which has close ties to Azerbaijan, condemned the attack, called for the perpetrators to be brought to justice and for measures to be put in place to prevent similar attacks in the future.
Turkey has backed Azerbaijan against Armenia over Nagorno-Karabakh.
“Turkey, which has been subjected to similar attacks in the past, deeply shares the pain of the Azerbaijani people,” a Turkish Foreign Ministry statement said.
“Brotherly Azerbaijan is not alone. Our support to Azerbaijan will continue without interruption, as it always has.”