Azerbaijan said on Monday it was suspending work at its embassy in Iran, days after a gunman stormed the mission, killing one guard and wounding two others.
Iran has said the attack on Friday was motivated by personal reasons, but Baku labeled it an act of terrorism.
"The operation of Azerbaijan's embassy in Iran has been temporarily suspended following the evacuation of its staff and their family members from Iran," Azerbaijani Foreign Ministry spokesman Ayxan Hacizada told Agence France-Presse.
"That doesn't mean that diplomatic ties had been severed," he said, adding that Baku's consulate general in the Iranian city of Tabriz was "up and running."
In a phone call on Saturday with his Iranian counterpart Ebrahim Raisi, Azerbaijani President Ilham Aliyev said he hoped "this violent act of terror would be thoroughly investigated."
Tehran's police said the attacker, who was arrested, was an Iranian man married to an Azerbaijani woman.
The United States condemned the "unacceptable violence" and urged a prompt investigation. Russia's Foreign Ministry said Moscow was "shocked" by the attack.
Iran is home to millions of Turkic-speaking, ethnic Azeris, and it has long accused Azerbaijan of fomenting separatist sentiment 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.