On orders from Panah Ali-khan, the ancient castles of Asgaran and Shah-Bulag, where the centre of the khanate was moved, were restored. In 1751, the construction of another castle began on a high steep mountain. The new centre of the Karabakh khanate was surrounded by rocks and high walls and was strongly fortified. initially, the castle bore the name of its founder – Panahabad, but then it adopted its previ- ous name Shusha or Shusha galasi and quickly turned into the eco- nomic centre of Karabakh, becom- ing one of the major cities of trade and craftsmanship in Azerbaijan. Caravan routes lied through Shusha, connecting the South Caucasus to Iran. Relying on the impregnable capital of Panahabad-Shusha, the Karabakh khan started to unite neighbouring Azerbaijani lands. As a result of successful military and political actions by Panah ali-khan, his supremacy was recognized by the khans of iravan, Nakhchivan, Ganja, Garadag and Ardabil. The territory of the Karabakh khanate expanded significantly.
Less than one year after the construction of the new castle, the Karabakh khanate was attacked by Muhammad Hasan-khan gajar, one of the main contenders for the shah’s throne in iran. Deciding not to besiege the strong castle, gajar and his troops stayed for a month far away from Shusha in the Khatun- arkhi area, for “he could not [even] approach the outskirts of the castle with such a [big] army” (Mirza Ja- mal Javanshir, ibid., p. 73). Having met with resistance and received news from iran about the start of a new fight for the shah’s throne, Gajar left Karabakh. His retreat was so hasty that he even left his cannons behind [ref]Mirza Adigozal-bey, ibid., p. 64[/ref].
Soon, Panah Ali-khan encountered a new threat from the south. in 1759, the Karabakh khanate was invaded by the 30,000-strong army of one of Nadir-shah’s famous military commanders – the ruler of Urmiya, Fatali-khan Afshar, who man- aged to subjugate all the southern regions of azerbaijan. He devastated a number of areas in Karabakh. as soon as the enemy troops set foot in Karabakh soil, some meliks betrayed their suzerain and de- fected to Fatali-khan: “The meliks of Chilaburd (Jeraberd) and Talish, who were covertly hostile to Panah khan, joined Fatali khan. They stayed near the castle for six months…” [ref]Mirza Jamal Javanshir, ibid., p. 74[/ref]. in a decisive battle, Fatali-khan’s troops suffered a major defeat.”
The military failures and the onset of the winter forced Fatali-khan to sign a peace treaty. The meeting between the two prominent rulers took place on aga Bridge near Shu- sha [ref]Mirza Adigozal-bey, ibid., p.70[/ref]. on the pretext of exchanging prisoners and marrying his daugh- ter to the elder son of the Karabakh khan, Ibrahim Khalil-aga, Fatali-khan managed to invite the heir to the khan’s throne to his camp. after that, declaring Panah ali-khan his vassal, Fatali-khan took his son hostage [ref]Mirza Jamal Javanshir, ibid., pp.74–75[/ref].
Soon, power in iran was seized by Karim-khan Zand, who launched an offensive on Urmiya’s Fatali-khan and won over Panah ali-khan of says: “Panah ali-khan, who always sought an opportunity to destroy Fatali-khan, immediately created an enormous army and large cavalry and went to help Karim-khan” (Mir- za Adigozal-bey, ibid., p. 72). The allies managed to gain a victory.
after that, Karim-khan freed ibra- him Khalil-aga from captivity and sent him to Karabakh as a khan, providing him with a special firman. as for his former ally, Karim-khan treacherously kept him as a hos- tage. Panah ali-khan died in Shiraz in 1763. His body, according to his will, was buried in Agdam in a place called imaret.
Thus, the Karabakh khanate emerged and strengthened in a fierce fight. in the middle of the 18th century, it occupied a vast territory.
The khanate included the whole of Karabakh. The melikdoms, as well as Zangazur, Hajisamli and Chalbair were under its jurisdiction. Panah ali-khan sought to expand the khan- ate at the expense of neighboring feudal possessions: he engaged in a lengthy fight for garadag, ganja and Nakhchivan. The Karabakh khanate always remained independent. “He [Panah-khan] did not serve anyone and did not put his neck under the yoke of obedience to anyone…” [ref]I. P. Petrushevskiy, Essays on the his- tory of feudal relations in Azer- baijan and Armenia in the 16th–19th centuries, Leningrad, 1949, p. 137[/ref].