Nadir Shah Afshar sent his army to Shaki. Haji Chelebi took refuge in the fortress of Gelesen-Geresen. In 1746, Haji Celebi was forced to recognize the authority of Nadir Shah. However, new uprisings and the death of Nadir Shah allowed Haji Chelebi to re-declare himself Khan During the existence of Shaki khanate, the local population of the city was engaged in silkworm breeding, craft and trade. As a result of a flood in the river Kish, the city of Shaki was partially ruined and the population was resettled in the present day city. In alliance with the Shamakhi Khan, in 1748 Haji Chelebi attempted to besiege the Bayat fortress. The defeat in the battle of Bayat, which lasted for a month, had been a serious setback for allies. The Jaro-Balakan Jamaat, Qabala and Ares sultanates were dependent on the Shaki khanate In 1751, Haji Chelebi defeated the army of the Kakheti king Heraclius II. At the initiative of Heraclius II, a political conspiracy of the Kakheti Kingdom, the Karabakh, Ganja, Irevan, Nakhichevan, and Karadag khanates against the Shaki khan was arranged. In 1752, in the area of Kyzylgaya, Georgian troops unexpectedly attacked the khans: they were captured. Haji Celebi himself defeated the Georgians in the battle near Ganja and came to the aid of the khans. The army of Shaki khan captured Gazakh and Borchali. In 1767, the Western part of the Shamakhi khanate was annexed to the Shaki khanate. In 1785, the Shaki khanate became dependent on the Guba khanate. However, this did not last long: after the death of Fatali khan of Guba, the Shaki khanate regained its independence. During the reign of Selim khan, the territory of the khanate was conditionally divided into 8 magals, which were ruled by naibs directly appointed by the khan himself. On May 21, 1805, the treaty of Kyurekchay was signed between Russia and the Shaki khanate, the main condition of which was the annexation of the Shaki khanate to Russia. In 1806, the Russian army moved to Shaki. Selim khan was removed from positions of power. A temporary Board of Pro-Russian beks was created. Modern era The area was fully annexed by Russia by the Treaty of Gulistan in 1813 and the khanate was abolished in 1819 and the Shaki province was established in its place. Shaki province was merged with provinces of Shemakha, Baku, Susha, Lankaran, Derbent and Kuban in