In the latter part of the 18th century, the Ganja khanate was one of the most economically prosperous polities in the Caucasus, benefiting from the strategic location of its capital on the regional crossroads. For this reason, two politically stronger neighbors, the Kingdom of Georgia and the Karabakh khanate, encroached on the independence of Ganja. From 1780 to 1783, the Ganja khanate was a condominium of Heraclius II of Georgia (represented by Prince Kaikhosro Andronikashvili) and Ibrahim-Khalil khan Javanshir of Karabakh (represented by the vizier, Hadrat Quli Beg). In 1783, Ganja rose up against its Georgian and Karabakh overlords. Georgians tried to reconquer Ganja at the end of 1784, but the campaign ended unsuccessfully. So did the Georgian invasions in 1785 and 1786. Under Javad Khan's rule from 1785 to 1804, the Ganja khanate grew in economic and political importance. The khans had their own mint in Ganja. In 1795, Javad Khan of Ganja joined the Iranian expedition against Georgia.
During the first Russo-Persian War (1804-1813) Ganja was considered by Russians, who had earlier supported Georgian claim to the sovereignty over the khanate, as a town of foremost importance. General Pavel Tsitsianov several times approached Javad khan asking him to submit to Russian rule, but each time was refused. On November 20, 1803, the Russian army moved from Tiflis and in December, Tsitsianov started the siege preparations. After heavy artillery bombardment, on January 3, 1804 at 5 o'clock in the morning, Tsitsianov gave the order to attack the fortress. After fierce fighting the Russians were able to capture the fortress. Javad khan was killed, together with his sons. According to a major study of the military events in the Caucasus by John F. Baddeley:
"Thus Gandja, on the pretence that from the time of Tamara it had really belonged to Georgia, though long lost to that country owing to the weakness of her rulers, was invaded, the capital city of the same name stormed after a month's siege (2 January 1804), Djavat Khan killed, and the khanate annexed. "Five hundred Tartars [Azerbaijanis] shut themselves up in a mosque, meaning, perhaps, to surrender, but an Armenian told the soldiers that there were some Daghestanis amongst them, and the name was a death-signal for all, so great is the exasperation of your Majesty's troops against those people for their raids into Georgia and the robber war they carry on", but all the women in the town were spared -- a rare occurrence in Caucasian warfare, and due to Tsitsianoff's strict injunctions."
Ganja was renamed Elisabethpol in honour of Alexander's wife Elisabeth. In 1805 the imperial government officially abolished the khanate and the military district of Elisabethpol was created. Descendants of Ziyad Oglu Qajar dynasty bore the name of Ziyadkhanov in the Russian empire.
^Akopyan, Alexander V (Autumn 2008). "Ganja Coins of Georgian Types, AH 1200–1205"(PDF). Journal of the Oriental Numismatic Society197 (Supplement: Caucasian Numismatics, Papers on the Coinage of Kartl-Kakheti (Eastern Georgia), 1744-1801): 47–52.
^John F. Baddeley, The Russian Conquest of the Caucasus, London: Longmans, Green and Co., 1908, p. 67, citing "Tsitsianoff's report to the Emperor: Akti, ix (supplement), p. 920".