Police stand guard in front of the Azerbaijan embassy in Tehran  following Friday's attack
Police stand guard in front of the Azerbaijan embassy in Tehran following Friday's attack AFP

A gunman stormed Azerbaijan's embassy in Tehran on Friday, killing the mission's head of security in an attack Iran said was motivated by personal reasons but Baku labelled an act of "terrorism".

Azerbaijan's foreign ministry said "responsibility" for the shooting, which also wounded two embassy security guards, lies with Iran -- with spokesman Ayxan Hacizada telling media in his country a recent anti-Azerbaijani campaign in Iran had "encouraged the attack".

Hacizada later told Turkey's state broadcaster TRT Haber that embassy staff were "being evacuated from Iran".

Leaked video footage from the embassy, widely shared on social media and published by Iranian media, shows two men parking a car and entering the building in eastern Tehran, before a speeding car approaches and crashes into the rear of their vehicle.

A man holding what appears to be a semi-automatic rifle is seen emerging from the second car and motioning to a security guard before forcing his way into the embassy.

Another unverified video apparently filmed inside the embassy shows two men entering and one of them opening the door in response to commotion outside, allowing a gunman to barge into the building and open fire.

One man appears to be struck in the torso by a bullet and collapses behind an internal door while the assailant is tackled by another guard.

An AFP photo shows what appears to be bullet holes in the front door of the embassy.

Following the attack, Azerbaijan's foreign ministry said the diplomatic mission's head of security was killed and that two guards were wounded but in a "satisfactory" condition, adding that an investigation had been launched.

Azerbaijan's President Ilham Aliyev said on Twitter that the attack was an act of "terrorism" and named the dead security officer as First Lieutenant Orkhan Rizvan.

Tehran's police chief General Hossein Rahimi said the attacker had been arrested and was an Iranian man married to an Azerbaijani woman.

"He claims his wife has been held at the embassy for nine months," Rahimi said on television.

Iran's foreign ministry spokesman Nasser Kanani said Tehran strongly condemned the attack, adding that the motivations behind it were "personal".

In a joint statement, Iran's foreign and interior ministries also insisted that "based on the evidence and preliminary observations the attacker fired with a very personal motive".

Early reports in Iranian media indicated the gunman had entered the embassy with his two young children, but they could not be seen in the videos shared online.

Another video posted on social media shows the body of a man lying in a pool of blood inside the embassy, surrounded by medical and security personnel.

A paramedic is heard saying in Azeri that the person "has no vital signs".

Iran is home to millions of Turkic-speaking, ethnic Azerbaijanis and it has long accused Baku of fomenting separatist sentiments inside its territory.

Relations between the two countries have traditionally been sour, with the former Soviet republic a close ally of Iran's historical rival Turkey.

Tehran also fears that Azerbaijani territory could be used for a possible offensive against Iran by Israel, a major supplier of arms to Baku.

Russia's foreign ministry spokeswoman Maria Zakharova said Moscow was "shocked" by Friday's attack.

"We offer our condolences and support to our Azerbaijani colleagues," she wrote on Telegram.

An AFP photo shows what appears to be bullet holes in the front door of the Azerbaijani embassy in Tehran
An AFP photo shows what appears to be bullet holes in the front door of the Azerbaijani embassy in Tehran AFP