The weakening of military-political power of Caliphate in the mid of the 9th century at the result of big uprisings in the border areas of the empire, interior squabbling and further development of feudal relations caused to the strengthening of the positions of provincial governors-emirs. Gradually, the authority of the dynasty of governors, who stayed in power inheritedly mixed with local people. This process was reflected also in the territory of Azerbaijan, where were established independent or half-dependent feudal states. Their governors gradually decreased the amount of taxes, payed to the Treausery and then refused to pay them at all. Obtaining real independence, these rulers recognized only spiritual authority of caliph over them. Even in the period of strong supremacy of Arabic Caliphate, there were existed feudal properties, depended on Arabs, such as in Beylagan, Shaki, Syunik, Gabala, Varsan and etc. in Northern Azerbaijan as well as in Arran. But they were independent only in interior affairs. Namely the uprising of Khurammids assisted to the establishment of independent and half-dependent states’ formations. Chronologically, the first among above-mentioned feudal state formations in the territory of Azerbaijan was the state of ShirvanShahs Mazyadids (861-1027); and in the southern part of the country the feudal state formations of Sajid (889-941), Salarids (941-981), Shaddadids (951-1088) and Ravvadids (981-1116) substituted one another. The capital cities of these 4 states were Ardebil and Tabriz.
The murder of caliph al-Mutavakil caused to the anarchy in the years of 861-870 and entered to the history of Arabic Caliphate in the phase of Abbasids as the period of anarchy. At the result of it, there were shaped political ambitions of local governors. Such ambitions about the establishment of independent states were shaped by governors of Shirvan from the dynasty of Mazyadids – the successors of the tribes of rabia, emigrated here by Arabs. Prominent Arabic general Salman ibn Rabia, who conquered Shirvan in the mid of the 7th century also came from this origin.
The founder of this state, who declared himself independent from Caliphate, was Heysam ibn-Khalid. His grandfather Yazid ibn Mazyad was the governor of Caliph in Armenia, Azerbaijan and then in Shirvan. He obtained profits from the properties of Shirvan and Arran. Yazid died in 801 and he was buried in Barda.
His father Khalid ibn Yazid has been the governor of Armenia and Azerbaijan till the year of 844. Heysam’s son, Muhammed ibn Heysam declared himself ShirvanShah. During the reign of the son of Muhammed, Heysam II the state of ShirvanShahs strengthened but his son Ali ibn Heysam began the war against khazars (912-913) together with the ruler of Derbend, at the result of which he and his troops, about 10 thousand soldiers were captivated.
Khazars settled these military captives among the population of Shendon, Khazar and Serir and they utilized them as slaves. Only some part of these captives could return to their motherland. Soon, ShirvanShah Ali ibn Heysam also came back to Shirvan. In the same year, when Heysam ibn Khalid declared the independence of the state of ShirvanShahs (in the year of 861), his brother Yazid ibn Khalid established the kigdom of Laydjanshakhs in the western Shirvan too. After the death of ibn Khalid the grandson of laydjanshakh, Abu-Tahir captured Shirvan and united both states under the sole dynasty of the state of ShirvanShahs in 917/918.
In the next year Abu-Tahir established the city of Yazidiyya (Shamakha), which became the capital of united realm of ShirvanShahs.
But during the reign of Abu-Tahir Shirvan was subordinated to Sajid, according to the sources who had to pay the tax of 1 million dirham too. Abu-Tahir reigned long and died in the year of 948. He was succeeded by his son Muhammed (948-956) and his grandson Ahmed (956-981); during the reign of Ahmed, the Salarids invaded Shirvan from the South and plundered this state. From the north, the emir of Derbend Ahmed gathered troops, especially from Serir and captured Shabran, the city of SirvanShahs. He plundered this city and burnt Shabran, as it was the trade-craft rival of Derbend. After the collapse of the dynasty of Salarids, the state of ShirvanShah re-obtained entire independence. Beside of it, the borders of Shirvan were enlarged at the expense 7 neighbourhood possessions.
After the death of Ahmed, his son Muhammed (981-991) became the shirvanShah for 10 years. In the first years of his ruling, Muhammed was able to capture ancient city of Gabala and include it to his state. In 983, he re-constructed the castle walls of Shabran. In the same year he captured Barda and appointed his governor Musa to this city. But Musa decided to separate from Shirvan soon. Neverthless, Muhammed managed to strengthen the authority of Shirvan over Derbend. But it’s important to mention that, the achievements of ShirvanShahs over Derbend were temporary, since these two possessions always fought for leadership.
In the reign of Muhammed’s brother, Yazid ibn Ahmed (991- 1027) state of ShirvanShahs was obliged to conduct interfeudal wars with its neighbors and defencive fough with foreign invader – Alanians, sarirs and Rus. Besides of it, Yazid’s son also rose against him but did not achieve anything. At that time, in the year of 1027, the reign of the dynasty of Mezyadids in Shirvan ended and the reign passed to the hands of Kesranids (1027-1382). During the reign of Manuchohr I (1029-1034) sarirs and alanians attacked to Shirvan, captured Yezidiyya (Shamakha) and killed 10 thousand people (in 1032). Staying in Shirvan, they plundered the country and took great wealth, but on their way to native land the settlers of Derbend gave back most of this wealth. Manuchohr was murdered by his brother Abu Mansur, by the vehicle of his wife Sitta. After the 10 years reign of Abu Mansur (1034-1043), he was succeeded by his brother Kubad (1044-1049), who constructed strong walls around of Yazidiyya. The next ShirvanShah, Salar (1049- 1063) established new city (Madina), he settled there lots of people and constructed council mosque there. In 1063, Fariburz-the son of Salar became ShirvanShah and during his reign Shirvan accepted its dependence under Seljukids, which we’ll talk about in the next chapter.