From the moment the Karabakh khanate was created it underwent attacks at the hands of the Iranian rulers and neighboring Azeri khanates.
As time passed, Panah Ali khan became convinced that the castle of Bayat was not a reliable refuge in the face of constant threat of interference from the neighboring khanates and increasing danger of invasion from Iran. He decided to move his residence to Shahbulak in the foot of the Khachin hill, but this place also appeared to be unfavorable by its climate and military-strategic position. The representatives of the Karabakh nobility called together to discuss the danger of Muhammed khan Qajar’s invasion from Iran told Panah Ali khan: «We must build among the impassable mountains such an inviolable and inaccessible fort, so that no strong enemy can take it»12. Thus, in 1751 a new fortress situated near Shushakend village was erected. Originally the fortress was called Panahabad, on behalf of its founder Panah Ali khan, and later it became famous among the people as Shusha.
Not even a year passed after Shusha was founded, when Muhammed Hassan khan Qajar attacked Karabakh, which he, as a representative of the clan of Qajar considered his hereditary estate. Courageous people of Karabakh inflicted great damage and losses to the attacking enemy. Having got news about another Iranian ruler Kerim khan Zend’s attack Muhammed khan Qajar who didn’t reach any of his military goals had to retreat in haste to Iran where fierce struggle for power was going on at the time. He even left under the walls of the Shusha fortress his cannons, which passed at the disposal of Panah Ali khan.
In 1756 Karabakh underwent a new attack of Fatali khan Afshar of Urmiya. Fatali khan together with his 30 thousand-strong army camped near Shusha and besieged the fortress. Soon, having used the hard situation the melik of Chelaberd Hatem and of Talish (Gulistan) Usub together with their detachments joined the enemy. Besiege lasted whole six months, but Fatali khan didn’t succeed in subduing Panah Ali khan. Then, Fatali khan resorted to fraud, and under the pretexts of hostage exchange and giving his daughter to Panah Ali khan’s son Ibrahim Khalil, invited the latter to his camp as a guest. After that, having declared Panah Ali khan his vassal, Fatali khan returned to his possessions, having taken with himself Ibrahim Khalil as an «honorable guest». Taking his son into hostage had heavily affected Panah Ali khan and soon he joined Karim khan Zend, who declared himself the ruler of Iran, in his struggle against Fatali khan Afshar. In 1763 Kerim khan Zend, together with his allies, Panah Ali khan among them as well, defeated Fatali khan Afshar.
After victory over Afshars, Kerim khan Zend liberated Ibrahim Khalil from captivity and together with his father’s troops sent him back to Karabakh, but didn’t risked to let Panah Ali khan go and took him with himself to Shiraz as an «honorable guest». He feared of Panah Ali khan as a potential force, which could hamper him to sit on the Iranian throne. Thus, Panah Ali khan, who tried to release his son from captivity and who achieved this goal, found himself virtually in captivity instead. Soon, Panah Ali khan died in enigmatic circumstances, not having said goodbye to Motherland. Kerim khan sent his remains with great honors to Karabakh, where he was buried in a place called Imarat, situated near Aghdam.
After Panah Ali khan’s death his son Ibrahim Khalil became a new khan of Karabakh (1763-1806). First of all, Ibrahim Khalil khan took measures to enforce his power. For this purpose, he had to subdue again some Armenian meliks, not willing to obey his authority, and also fight with some neighboring Azeri feudal lords, in particular, with Fatali khan of Kuba khanate. This hostility didn’t lead to anything good but destruction of several villages.
- Mirza Jamal Jevanshir Karabagi (1773-1853) «History of Karabakh», «Karabakhnameh» Baku 1989 p. 115;