Courageous resistance of Shushavians to the invasion of Iranian troops headed by Agha Muhammad khan in 1795 is the brightest page in the history of Karabakh khanate.
After victory over his enemies – the representatives of the Zend dynasty, Agha Muhammad khan, from a noble family of Qajars and son of Muhammad Hassan khan Qajar, who attacked Karabakh in 1751, decided to restore the borders of the former Safavid State, before his coronation as shah (king) of Iran, since, according to the political tradition in Iran, shah, had to take control over the whole South Caucasus before coronation.
Already in 1794 he sent a 4 thousand-strong detachment against the Karabakh and Erivan khanates. But Ibrahim Khalil khan, supported by the Georgian detachment headed by prince Alexander, defeated this detachment. Defeat of the Iranian troops in Karabakh became an incentive for the decisive military campaign.
By summer 1795 Agha Muhammad khan Qajar, approximately with army of 80 thousand, besieged Shusha. But Ibrahim Khalil khan had prepared well for the attack. He had fortified the fortress and mobilized the Karabakh population. Only in Shusha the number of the militia reached 15 thousand. Women also participated in defending Shusha together with men. Ibrahim Khalil khan frequently organized daring attacks and counterattacks from the besieged fortress thus making the enemy to panic.
It also has to be noted, that the Armenian population of Karabakh also actively participated in struggle against the invaders and fought side by side with Azeris along with them organizing ambushes in the mountains and forests. Besieger lasted 33 days. During this period the number of Agha Muhammad khan’s troops considerably decreased, many cannons were out of order, the spirit of the Iranian army greatly fell down. The historian Mirza Adigezal bey recorded the words allegedly said by Agha Muhammad Qajar: «It’s better to return from halfway, rather than to stay and underwent a full defeat».
Not being able to capture Shusha, Agha Muhammad khan ceased besieger and advanced to Tiflis (present-day Tbilisi), which despite desperate resistance was occupied and exposed to unprecedented destruction. In 1797 Agha Muhammad shah Qajar, who by that time has already managed to declare himself shah (albeit he couldn’t according to the tradition, conquer the Caucasus) decided to carry out a second attack to Karabakh and to take revanche.
The main objective of Qajar’s military campaign was, as before, Karabakh with its inaccessible fortress Shusha. Trying to revenge for the previous humiliating defeat Qajar devastated the surrounding Karabakh villages.
The situation of the Karabakh khanate, which didn’t recover from the enemy’s last invasion, was desperate also because of the draught, which had raged for 3 years. All of these, certainly, had very negative effect on the defence ability of the Karabakh population. The artillery of the enemy caused great losses to the defenders of Shusha.
Proceeding from all these facts, Ibrahim Khalil khan decided to risk and fight with more powerful enemy in the open field and to destroy its artillery. A fierce battle took place and albeit the Karabakhis succeeded in destroying the enemy’s artillery, many of them died in the battlefield. Qajar’s troops, which exceeded in number those of Ibrahim Khalil khan closed the way for retreat to the fortress and Ibrahim Khalil khan had no choice but to run to his relative Umma khan of Dagestan.
Left without leadership the fortress defenders realized, that in this situation the best option would be surrendering of the fortress based on a certain security guarantees. And after Agha Muhammad shah swore on Koran, that nobody would be punished in Shusha, the defenders of the fortress-town decided to open the gates.
But as soon as shah Qajar took Shusha, he ordered his troops to begin looting. Only sudden and enigmatic death of Agha Muhammad shah Qajar, which happened in several days after capture of Shusha, spoiled the plans of this usurper. The Iranian troops left without head run away and soon afterwards, Ibrahim Khalil khan returned to Shusha and restored his authority as khan of Karabakh.