After defeating an Aq Qoyunlu army in 1502, Ismail took the title of "Shah of Iran". In the same year he gained possession of Erzincan and Erzurum, while a year later, in 1503, he conquered Eraq-e Ajam and Fars; one year later he conquered Mazandaran, Gorgan, and Yazd. In 1507, he conquered Diyabakir. During the same year, Ismail appointed the Iranian Amir Najm al-Din Mas'ud Gilani as the new "vakil". This was because Ismail had begun favoring the Iranians more than the Qizilbash, who, although they had played a crucial role in Ismail's campaigns, possessed too much power and were no longer considered trustworthy.