The statehood of Azerbaijan was restorated with the formation of khanates. This was proved with the independent foreign policy, which was conducted by khans. But khanates were weak from military-political viewpoint. Local strife weakened them much. That is why, khanates shaped relations with Iran, Turkey, Russia and Kartli-Cakhetia, did their best to preserve their own independence by maneuvering among them.
In the 60s of the 18th century, Kerim khan Zend, who attempted to create centralized state under his own authority in Iran, subordinated the khanates of Southern Azerbaijan. Several khanates, such as Quba and Karabakh khanates in Northern Azerbaijan were able to preserve their independence and avoid from the aggression of Kerim khan Zend. There occurred exchange of embassies between Kerim khan and Fatali khan in 1775-1776s. Neverthless Kerim khan never refused from his plans about the conquest of Northern khanates, as well as Quba khanate. But the strengthening of these khanates and pressure of Russia did not allow Kerim khan to attain to his aim.
The relation between Azerbaijan khanates and Ottoman Empire were much more essential. There was formed Russian-Georgian block in the region at that time. Ottoman Turkey, which always was the object of the attacks by Russia, attempted to create coalition against this block by the vehicle of Muslim countries and with this aim he sent his envoys to Azerbaijan.
In 1770 and in 1771, there was sent special embassy to Quba khanate, Russia observed these actions of Ottoman-Turks with great danger. This was obvious, since that time Russia conducted war with Turkey and such approach of relations among Turkish-Muslim countries disturbed the Northern empire. Sunnite clergy of Shamakha khanate played an important role in these relations. Russia did his best to violate these relations with all vehicles.
After Russian-Turkish war of 1768-1774s, the relations between Azerbaijan khanates and Ottoman Turkey improved. Most khanates were eager to pass to the patronamy of Turkey in the case of Russian aggression. But, Quba khan-Fatali khan appealed to the aid of Russia after the defeat in Gavdushan battle. In 1775, the Russian army, commanded by general de-Medem came to aid Fatali khan and he could overwhelm his enemies. By this action, Russia pursued its goals: it wanted to punish Amir Hamza Garaqaytaqly-the enemy of Fatali khan in Gavdushan battle.
In 1775, Fatali khan sent embassy, led by Mirza bey Farhadbeyli to the palace of Ekaterine II. In his letter to emperor, Fatali khan requested the patronamy of Russia and giving the khanate the same status, as to Crimea khanate and Eastern Georgia. According to the conditions of Kuchuk-Qaynarca treaty, Crimea was proclaimed independent. Fatali khan wanted to apply the status of “independent” Crimea to Azerbaijan too. In other words, the khan wanted to preserve his sovergnity under the protection of Russia and in the substitution of this, he sent the keys of Derbent to Ekaterine II. But Russia rejected the suggestion of Fatali khan with an excute that Quba khanate was located in the structure of Iran and Russia, maintained friendship relations with this neighbourhood states. But further events proved that Russia attempted to obscured her plans about the conquest of Azerbaijan with this measure. The suggestion of Fatali khan was not convenient for Russia and that is why, she refused the recognition of independence of Quba khanate. In the summer of 1775, Russian troops were called back from Azerbaijan. So, the embassy, which was sent to Russian palace could not implement its duty.
On June 24, 1783, there was concluded agreement in Georgiyevsk about the entering of Kartli-Cakhetia to the protectorate of Russia.
According to the conditions of the agreement, Irakly II recognized superior authority of Russian Empire from his name and from the name of his successors, the heir of the throne should be confirmed in Petersburg. Russian side brought several certain obligations also the guarantee of the integrity of the territory and the defence of Kartli- Cakhetia realm; guaranted the integrity of Kartli-Cakhetia, rights of Irakly’s and his successors’ to the throne; Georgian tsar preserved internal self-control of the state, but in foreign policy he had to take into account the thoughts of Russian officer, whose residence was located in Tiflis. Russia promised to protect Georgia from foreign enemies, the rights of Georgian feudals equaled to the rights of Russian aristocracy.
Due to bring military forces from Russia, there began the construction of the strategically essential military-Georgian way and on its basic there was set the Vladicaucasus castle.
In November of 1783, Russian troops entered to Tiflis and soon the commander of the Russain troops in the Caucasus-general R.S.Patyomkin sent universals about the concluding of tractate to Azerbaijan khans. Along with universals, there were sent “circulated letters”, in which the commander offerred to Azerbaijan khans to create their further relations with Georgia, since it was under the protectorate of Russia.
Generally, the relations of Georgia and Azerbaijan khanates were not stable. As it was mentioned above, in the 50s of the 18th century, the relations between Sheki khanate and Irakly II were strained. Georgia wanted to conquer not only Sheki, but also other Azerbaijan khanates, which Kizilkaya betrayal proved about. Eastern Georgia continued its agressive policy about Azerbaijan khanates in 60s too. This policy disagreed Quba khanate. Ekaterine II, who did her best not to permit the strengthening of any state in the Caucasus, ordered the Collegie of foreign affairs to make an order in the relation between Eastern Geogia and Quba khanate in 1770. Neverthless, Irakly II also participated along with Sheki, Shamakha and Daghestan governors in the campaign along with Quba khanate.
The relations between Karabakh and Georgian states were friendly at the beginning of 80s of the 18th century. In 1780, they conquered Ganja khanate together. But after Georgiyevsk tractate in 1783, Irakly II attempted to withdraw Ibrahimkhalil khan from Ganja. Ibrahimkhalil khan attained to withdraw Georgian representative from Ganja. After this event leading powers of Russia together with Irakly II, began to rise meliks against the khan. In 1787, Russian and Georgian troops prepared to attack to Karabakh. But the beginning of Russian- Turkey war spoiled these plans. Since the end of 80s, Irakly II and Ibrahimkhalil khan again became friends.
The khan of Karabakh was not consecutive in the relations with Russia. In 1782, Ibrahimkhalil khan sent an embassy to Russia and expressed his attitude to this state. The one of pro-Russian political leaders in Azerbaijan was the vezir of Karabakh – Molla Penah Vaqif. The approachment of Karabakh khanate with Russia and Georgia was related with growing danger from the side of Iran.
The demand of Agha Muhammed Shah Qajar about the subordination brought Irakly II and Fatali khan together. In 1787, there was concluded political alliance between North-Eastern Azerbaijan and Eastern Georgia.
In the same year, there was sent embassy of Quba khanate, led by Mirza Sadiq Mammedaliyev to Petersburg. In his letter to Ekaterine II, Fatali khan again expressed his devotion.
So, Azerbaijan khans did their best to conduct independent foreign policy in difficult circumstances. Major goal of the khans was the maintainance of the intergrity and independence of their states. But, these states were small and weak in separate. Due to prevent the attacks of their enemies they should be united. Unfourtanately, the unification of Azerbaijan lands was not successful in the second half of the 18th century. The provision, given by history was missed. Several khans believed to the promise of Russia in the search of powerful support.