Shaykh Ali Khan

Although he was supported by Dagestani rulers, siege coupled with rainy weather, attrition, lack of supplies and the army became incapacitated.

However thanks to the intervention of utsmi Ali Bek and qadi of Tabasaran sides signed a truce in the village of Koysu.

[7] Agha Muhammad Qajar's arrival in South Caucasus triggered with expedition of Valerian Zubov in 1796, who besieged Shaykh Ali's castle with more than 12,000 soldiers for 2 months.

[9] Zubov arrested Shaykh Ali Khan, while appointing his pro-Russian half-sister Pari Jahan Khanum as head of the Derbent Khanate.

[11] Shaykh Ali however managed to escape to [9] near Gilgilçay,[12] reached Kumukh asked for troops from Surkhay II to retake Quba.

As a result of disastrous battle near Alpan, 1600 Dagestanis died, including Surkhay's son Bayram, as well as councillor Molla Taghi.

Pari Jahan, meanwhile, agreed to marriage proposal from Mehdi, Shamkhal of Tarki and wed another half-sister Chimnaz to Abdulla beg, son of Ghāzī Rustam of Tabasaran.

[15] After departure of Russian troops from Caucasus and assassination of Agha Muhammad Qajar on 17 June 1797, Shaykh Ali managed to reconsolidate his dominion over Quba and Derbent and sent his ambassador Manaf beg to Saint Petersburg to put forward claims to Baku Khanate again.

[17] Shaykh Ali khan managed to expel his armies only after support of 10,000 soldiers from Akusha-Dargo Union and Shamkhalate of Tarki and routed him till Chirag.

[18] This rebellion was followed by a famine in 1799 when the inhabitants had to fight off 400 carts en route from Tarki to Quba bringing food and supplies to capital, accusing khan of debauchery and only thinking for himself.

As a middle ground, Shaykh Ali accepted his half-sister and Mirza Muhammad's wife Khanbika khanum as hakem of Derbent and Sultan as her deputy.

Surkhay II heard rumours of Shaykh Ali later and decided to attack Quba and install his puppet Hasan as khan there.

Using opportunity Shaykh Ali raided Derbent Khanate and forcibly moved population of 9 villages to Quba, depriving Hasan of his tax income.

Having suffered defeat after several battles, the Russians now afraid of Shaykh Ali's reinforcements, boarded the ships and retreated to the island of Sari (near Lankaran) on 29 September [O.S.

Arriving at an empty city, Bulgakov formally annexed the Quba Khanate and appointed Haji beg of Budukh as a naib and provisional governor.

Attack was success as Russians reported in August 1810 that the inhabitants of Quba and the local beys had gone over to side of Khan.

Shaykh Ali had 7,000 under his command, being aided by Surkhay II's son Nuh bek, Aslan Khan of Dzhengutay and Qadi Abubekr of Akusha-Dargo.

Khotuntsov attacked the village from three sides and, after a 4-hour stubborn battle, drove out Shaykh Ali to Akhty, captured many prisoners, recaptured 30 banners and more than 350 horses.

[24] Shaykh Ali joined Dagestani rulers in their defence against general Yermolov's subordinate Pestel near Bashlykent on 23 October 1818.

Shaykh Ali and Abdullah left the alliance for Quba on the 4th day of siege, reportedly after searching for the corpses of Russian soldiers and cutting off ears and hands, having collected a whole bag of them to turn over to Abbas Mirza in return of monetary support to gather more armies.

8 Derbent beys were exiled to Astrakhan on suspicion of being allied to Shaykh Ali, one of them being Haji Qasim, father of Mirza Kazembek.

Battle plan of siege of Derbent
Borders of Quba during Shaykh Ali's reign
Silver coin minted in Derbent during Shaykh Ali's reign in 1805