For a short period, Ganja was renamed Abbasabad by Shah Abbas after war against the Ottomans. He built a new city to the southwest of the old one, but the name changed back to Ganja during the time. During the Safavid rule, it was the capital of the Karabakh province. In 1747, Ganja became the center of the Ganja Khanate for a few decades following the death of Nader Shah, until the advent of the Iranian Zand and Qajar dynasties. The khans/dukes who de facto self-ruled the khanate, were subordinate to the central rule in mainland Iran and were from a branch of the Iranian Qajar family.