A gunman has killed the security chief at the Azerbaijani embassy in Iran.

Two other security forces were injured, the Azerbaijani Foreign Ministry said on Friday.

According to Tehran's police chief Hossein Rahimi, the attacker, who acted for "personal" reasons, was arrested.

Accordingly, the Iranian is married to an Azerbaijani woman.

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

The police chief told Tasnim news agency that the attacker "entered the embassy with his two young children."

Rahimi said that an Azerbaijani national was killed and that it appeared to be a member of the embassy.

Azerbaijani President Ilham Aliyev wrote on Twitter that he "strongly condemned the terrorist attack".

The State Department said that "all responsibility for this attack rests with Iran."

A recent anti-Azerbaijani campaign in Iranian media "encouraged" the attack.

The ministry spokesman said staff at the embassy in Tehran would be evacuated.

Iranian Foreign Ministry spokesman Nasser Kanani said Tehran strongly condemned "the armed attack (...) which unfortunately resulted in the death of one person".

According to preliminary investigations, it is about personal motives.

Iran is home to millions of Azeris, an ethnic group mainly represented in Azerbaijan, Russia and Iran.

Tehran has long accused Baku of fueling separatist sentiment.

Relations between the two countries have traditionally been poor as Azerbaijan is a close ally of Iran's historic rival Turkey.

Russian Foreign Ministry spokeswoman Maria Zakharova said on Friday Moscow was "shocked" by the attack.

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