In the conversation, President Raisi extended condolences to Aliyev over the death of a staffer of the Azerbaijani Embassy in the incident.
He said that brotherly ties between Iran and the Republic of Azerbaijan are built on unbreakable cultural and historical bonds.
Raisi added that Iran and Azerbaijan will not let their good ties be affected by ill-wishers.
The Azeri president for his part thanked President Raisi for extending condolences to the government and people of Azerbaijan.
He described the attack as an unexpected crime, noting that cooperation between Tehran and Baku should be such that no one can use it as a pretext to disrupt friendly relations between the two countries.
The attacker was detained immediately after entering the Embassy building and opening fire of staff there on Friday.
He said that he carried out the attack because the Azerbaijani Embassy ignored his requests for information about his wife who is from the Republic of Azerbaijan.
The man added that his wife once went to the Azerbaijani Embassy and never returned home.
According to him, the woman later ended up in Azerbaijan.