The origins of the conflict

Nadir Shah — ruler of Persia in 1736-1747, military leader

Having fought a fierce war against the Turks, the Armenians of Artsakh valiantly proved themselves, so the new powerful ruler of Iran, Nadir Shah, confirmed the authority of the Armenian princes of Artsakh and their system of self-government in a union association called the Melikdom of Khamsa in 1736. Prince Yegan was appointed the general governor of the Melikdom of Khamsa. He was directly subordinated to Nadir Shah's brother Ibrahim Khan, who ruled from Tabriz. It was quite a high level of self-government.

But due to the fateful circumstances that took place after the death of Nadir Shah, the destiny of Artsakh changed in a most dramatic way. Shahnazar the Second, taking advantage of the chaos that arose after the assassination of Nadir Shah in 1747, killed his elder brother Melik Hovsep and his whole family and proclaimed himself prince of Varanda.

Such an act aroused the anger of other princes, and the latter organized a campaign to kill Prince Shakhnazar. Realizing that he himself was unable to wage war against other princes, Shakhnazar in despair appealed for help to Panah Khan, the head of the Turkic tribe of Jevanshirs that lived nearby. Subsequently, Shahnazar gave his daughter in marriage to Panah Khan's son and allowed them to settle in the heart of Artsakh, in the fortress of Shushi. He also helped Panah Khan financially for many years, such was the price of saving his life.
The report of A.V. Suvorov sent from Astrakhan to Prince G.A. Potemkin stated the following:

"This traitor of his fatherland has called Panah khan, the former chief of the ignorant part of the nomadic Mohammedans near the borders of Karabagh, gave him his strong castle Shushikala and became obedient to him with his signag.
Panah Khan understood that luck alone was not enough and the hostile region had to be diluted with kindred tribes and co-religionists. To this end, by promising various privileges, the Khan invited Turkic nomadic tribes from neighboring regions.

The struggle of the local Armenian population with Panah Khan and his son Ibrahim Khan continued for many years. This conflict continued until 1813, until the lands of Artsakh were included in Russia, and in 1822 the Karabakh Khanate was abolished.
Conclusion: The struggle of the people of Artsakh is the struggle of the autochthonous Christian people with the nomadic tribes that came over.

The outbreak of the conflict

On March 23, 1920 there was a massacre of Armenian population in Shushi town in Karabakh. Armenian quarters were ravaged and burned, one of the most important cities in the Caucasus lost its importance and could no longer regain it — not during the Soviet years and not later.
After the overthrow of the monarchy in Russia, the turmoil began, and Russia's influence in the southern Caucasus weakened sharply. Since 1918, in the mountainous regions of Syunik (Zangezur) and Artsakh (Karabakh) disagreements over the administrative definition of the regions began. The newly formed Azerbaijani Democratic Republic declared the territories as an integral part of Azerbaijan.

At the same time, the local Armenian population did not consider this division legitimate and opposed it, forming the Armenian National Council. Since 1918 the fate of Artsakh was uncertain and the tension was growing. All this led to tragic pogroms and massacres of the Christian population in Shushi.
Reminiscences of the Soviet writer and poetess Marietta Shahinian about Shushi in the second half of the 1920s:

"I was stunned by the silence. I had never felt such a terrible, artificial silence. Suddenly the silence seems to mumble, the stones whisper, move and pounce, and make my hair stand on end. In March 1920 in three days 7000 houses were destroyed and burned here, according to some people 3-4 thousand Armenians were slaughtered and according to others more than 12 thousand. The fact is that none of the 35 thousand Armenians remained in Shusha. Somewhere in the stream you can still see women's hair covered in black blood. It's hard for a person with a good imagination to breathe here. You walk, you walk, you walk through rows of charred buildings, or rather pieces of walls, you hurry, fearing that you will never get out of here".
Modern Azerbaijani historian Arif Yusuf justifies the massacre of civilians in Shushi, describing the reasons as follows:

"While Armenian troops were massing in Zangezur, the Dashnaks launched an extensive propaganda campaign in Karabakh. Meanwhile, the situation in Azerbaijan was extremely difficult, as the troops of Soviet Russia in January 1920 approached the border of Azerbaijan. And in such a situation, on the night of March 23, 1920, when Muslims celebrated their New Year (Novruz), Armenians suddenly attacked Azerbaijanis in Shusha and other settlements of Karabakh. This attack and the attack by Armenian units forced the Azerbaijani government to throw almost all of its armed forces into Karabakh".
Conclusions: All attempts by the newly formed Azerbaijan to incorporate the region into its own territory, without any historical or international legal basis, were inclined to resolve the issue by force, which resulted in ethnic cleansing.