After the conquest of the country by Arabs Karabakh, the constituent part of Christian Albania, remained a part of Azerbaijan. But after the fall of Arab dominance, Karabakh was included step by step into the territories of Azeri feudal states. In the nineth and tenth centuries Karabakh was under the Sadjids‟ power, in the tenth under the Salarids, in the eleventh and twelfth, the Shaddadids, in the twelfth and thirteenth centuries, the Ildenizids.
After two centuries under the Mongolian yoke in the thirteenth and fourteenth centuries the local Turkish dynasties Kara-Koyunlu and Ak-Koyunlu, who played an important role in the Middle East at that period of time, reigned in Azerbaijan in the fifteenth century. Despite the current widespread opinion among Armenian researchers, the Turkish leaders of Kara-Koyunlu and Ak-Koyunlu treated the Armenians and Albanians very highly and provided them with all kinds of patronage. The consequence of such a policy was the removal of the center of the Armenian Catholicos in 1441 from the city of Sis in Asia Minor to Echmiadzin in the territory of modern Armenia. This policy of the Azeri rulers led to a situation in which at that period of time Armenians even had hopes of restoring the Armenian realm with the help of the Azeri Turks. Although those hopes were not realized, they are, however, very demonstrative in understanding the attitude of the Muslim- Turks of Azerbaijan toward their dependent Christian population. In the early sixteenth century Azerbaijan beca me the part of the Safavid state, one of the leading states of the Middle East. It was then that Safavid rulers divided the state into a number of areas, or beglarbekts, one of which was Karabakh. By the end of the sixteenth century the tribe of Djevanshirs, which headed 32 local Turkish tribes, arose in the territory of Karabakh. For that reason, the union of Karabakh tribes was sometimes named “Otuz iki” (“thirty two”). At the same period of time there was a considerable resettlement of Kurds from Iran to Karabakh. According to a sixteenth century K urdish historian, “twenty four K urdish families live in Arran Karabakh and are known under the common name “Igirmi dort” (“twenty four”- A.Y.)”.
In the early eighteenth century the Safavid state experienced a serious crisis and the Ottoman and Russian empires took advantage of that and tried to invade Azerbaijan. The Ottoman and Russian armies virtually simultaneously started their campaigns. Each party counted on the support of the population: the Ottoman Turks hoped for the support of the Muslim population and the Russians relied on Christians. However, on 20 March 1724, an event occurred in Karabakh which would be considered fantastic in the light of contemporary Azeri- Armenian interrelations: the Christians of Karabakh concluded a pact of friendship and mutual aid with the local Muslims. According to that pact, in case of an attack by outside forces on Karabakh, Azeris and Armenians would help each other. But if one side should be refused “its friendship and debt of neighborhood,” the other side would be called “traitor, coward and false to its promise” .
Nevertheless, in the 1720s the whole territory of Karabakh ended up under the authority of Ottoman Turkey, which in 1727 took the first census of the population in the history of the region. It appeared that in 1,179 populated areas and in 478 villages (40.5%) (Turkish were the overwhelming majority), there were no inhabitants. 11,818 Muslim families (11,068 out of them were Turkish and 750 K urdish) and 7,577 Christian ones lived in the rest of the settlements(43).
In 1747, the Karabakh beglarbek achieved its independence and began to be called the Karabakh khanate. Panah Ali-khan became the founder of that Azeri khanate. The khanate also included the mountain districts of Karabakh populated by Christians. Moreover, as it was said in a historical essay of that period, the most authoritative among the Karabakh Armenians, Melik (prince) Shakhnazar “underlined his loyalty and love to the khan in all possible ways”. He gave his daughter in marriage to the son of the khan and the future ruler of the Karabakh khanate, Ibrahim K halil. It was expressly according to the advice of Melik Shakhnazar that in 1754 Panah Ali-khan built a fortress-city which was originally named Panahabad in honor of its founder and became the capital of the khanate. A little later the city was renamed Shusha after a village of the same name situated nearby.
The Karabakh khanate achieved prosperity in the reign of the successor and son of Panah Ali-khan, Ibrahim K halil-khan (1759-1806). In 1795, at the end of his reign, Iranian troops, trying to restore their authority, undertook a devastating campaign against the khanates of Northern Azerbaijan. Many areas of Azerbaijan were defeated. The Iranians also attacked the Karabakh khanate. For 33 days the invaders unsuccessfully besieged Shusha, which was protected by Azeris and Armenians together. Finally, the siege was lifted and Iranian troops left the territory of the Karabakh khanate. However, the threat of the new inroad made by Iranian troops remained and under those conditions in 1796 Ibrahim K halil-khan applied for the help and patronage of the Russian empire.