The last decades of the 18th century were marked by continual strife between rival claimants to the Peacock Throne. Catherine the Great of Russia took advantage of the disorder to consolidate her control over the weak polities of the Caucasus. The kingdom of Georgia became a Russian protectorate in 1783, when Erekle II signed the Treaty of Georgievsk, whereby the Empress promised to defend him in case of the Iranian attack. The shamkhals of Tarki followed the lead and accepted Russian protection three years later.
With the enthronement of Agha Mohammad Khan as Shah of Persia in 1794 the political climate changed. He put an end to the period of dynastic strife and proceeded to strengthen the hold of the Caucasus by ravaging Georgia and reducing its capital Tbilisi to a pile of ashes in 1795. Belatedly, Catherine II determined to mount a punitive expedition against the Shah.
Although it was widely expected that a 13,000-strong Russian corps would be led by a seasoned general (Gudovich), the Empress followed the advice of her lover, Prince Zubov, and entrusted the command to his youthful brother, Count Valerian Zubov. The Russian troops set out from Kizlyar in April 1796 and stormed the key fortress of Derbent on 10 May. The event was glorified by the court poet Derzhavin in his famous ode; he was later to comment bitterly on Zubov's inglorious return from the expedition in another remarkable poem.
By mid-June, Zubov's troops overran without any resistance most of the territory of modern day Azerbaijan, including three principal cities — Baku, Shemakha and Ganja. By November, they were stationed at the confluence of the Araks and Kura Rivers, poised to attack mainland Iran.
It was in that month that the Empress of Russia died and her successor Paul, who detested the Zubovs and had other plans for the army, ordered the troops to retreat back to Russia. This reversal aroused the frustration and enmity of the powerful Zubovs and other officers who took part in the campaign: many of them would be among the conspirators who arranged Paul's murder five years later.