[custom_adv] The Qajar rulers were members of the Karagöz or "Black-Eye" sect of the Qajars, who themselves were members of the Qajars (tribe) or "Black Hats" lineage of the Oghuz Turks. Qajars first settled during the Mongol period in the vicinity of Armenia and were among the seven Qizilbash tribes that supported the Safavids. [custom_adv] The Safavids "left Arran (present-day Republic of Azerbaijan) to local Turkic khans", and, "in 1554 Ganja was governed by Shahverdi Soltan Ziyadoglu Qajar, whose family came to govern Karabakh in southern Arran". [custom_adv] Qajars filled a number of diplomatic missions and governorships in the 16–17th centuries for the Safavids. The Qajars were resettled by Shah Abbas I throughout Iran. The great number of them also settled in Astarabad near the south-eastern corner of the Caspian Sea, and it would be this branch of Qajars that would rise to power. [custom_adv] The immediate ancestor of the Qajar dynasty, Shah Qoli Khan of the Quvanlu of Ganja (also spelled Ghovanloo or Ghovanlou), married into the Quvanlu Qajars of Astarabad. [custom_adv] His son, Fath Ali Khan (born c. 1685–1693) was a renowned military commander during the rule of the Safavid shahs Sultan Husayn and Tahmasp II. He was killed on the orders of Shah Nader Shah in 1726. Fath Ali Khan's son Mohammad Hasan Khan Qajar (1722–1758) was the father of Mohammad Khan Qajar and Hossein Qoli Khan (Jahansouz Shah), father of "Baba Khan," the future Fath-Ali Shah Qajar. Mohammad Hasan Khan was killed on the orders of Karim Khan of the Zand dynasty. [custom_adv] Within 126 years between the demise of the Safavid state and the rise of Naser al-Din Shah Qajar, the Qajars had evolved from a shepherd-warrior tribe with strongholds in northern Persia into a Persian dynasty with all the trappings of a Perso-Islamic monarchy. [custom_adv] "Like virtually every dynasty that ruled Persia since the 11th century, the Qajars came to power with the backing of Turkic tribal forces, while using educated Persians in their bureaucracy". In 1779 following the death of Karim Khan of the Zand dynasty, Mohammad Khan Qajar, the leader of the Qajars, set out to reunify Iran. [custom_adv] Mohammad Khan was known as one of the cruelest kings, even by the standards of 18th-century Iran. In his quest for power, he razed cities, massacred entire populations, and blinded some 20,000 men in the city of Kerman because the local populace had chosen to defend the city against his siege. [custom_adv] The Qajar armies at that time were mostly composed of Turkoman warriors and Georgian slaves. By 1794, Mohammad Khan had eliminated all his rivals, including Lotf Ali Khan, the last of the Zand dynasty.