In the last third of the 10th century there was shaped new state formation under the leadership of the representatives of Shaddadids dynasty (951-1088). The founder of this state was Muhammed ibn Shaddadid (951-971) and the capital of Shaddadids was Gandja. The major branch of the dynasty of Shaddadids, ruled in one of the biggest muslim cities of that time-Ani (the ruing of the city is located in the territory of Eastern Turkey). In 951, Muhammed became the head of the city of Dabil and his son Fazl emigrated to Gandja in 966/967.
At that time, Gandja and the lands, concerned to this city were invaded by alanian and siyavurd tribes. The reis of Gandja-Ali at-Tazi organized the defense of the city against siyavurds together with Fazl. So, urban population managed to withdraw siyavurds from Gandja.
After this event the population of Ganja began to respect Fazl much. Fazl lived in Ganja till the year of 359 (Hijri), i.e. in 969-970 s. Fazl invited his brother Lashari to Ganja by the request of population.
In 971, settlers of Ganja arrested the Salarid naib, al-Aziz by the advice of the new reis of the city, Yusif al-Quzzaz and encountered Fazl and his brother in the gates of the city. According to the agreement, Lashkari ibn Muhammed accepted the throne. So, with the active participation of Fazl, Shaddadids completely occupied their future capital from the emir Ibrahim and founded new feudal state in the territory of Northern Azerbaijan – emirate of Shaddadid in Ganja. In 971/72 Ibrahim approached to Ganja with his army and encircled the city. But after a long besiege he understood that, Ganja couldn’t be captured and that’s why Ibrahim concluded treaty with Lashkari and returned to Ardebil.
According to this treaty Ganja was preserved in the hands of Lashkari and Shaddadids. After that, Lashkari began to fortificate the city and did his best to strengthen both his power and state by enlarging the territory of Shaddadids.
So, firstly the leader of the new emirate became the elder son of Muhammed, Lashkari, then his second son Marzban (978-985). Namely, during his reign ShirvanShah Muhammed ibn Ahmed temporarily conquered the main city of Arran-Barda in 982/83 and appointed Musa ibn Ali as the ruler of the city.
Emir Marzban was murdered during hunting by the third son of Muhammed, his smallest brother, Fazl I, who became the leader of Ganja emirate of Shaddadids for 47 years (985-1031). Fazl did not only return Barda, but also captured Beylagan, Khachen, Syunik and other small feudal possessions in Arran.
The emirate of Shaddadids strengthened in the presence of Fazl I.
Fazl built the Khudaferin bridge over the river of Araz in 1027, which intensified the extension of economic and trade relations between southern and northern regions of Azerbaijan. Khudaferin bridge possessed military importance too.
Shaddadids utilized from the “marriage diplomacy”, for strengthening own positions. For instance, at the expense of the marriage of emir with the daughter of ShirvanShah, the relations between two states improved.
There happened uprisings against Fazl during his reign. In 1030, one of the sons of Fazl – Askariyye declared himself independent, settled in Beylagan and rose against his father. The old Fazl sent the troops to Beylagn under the leadership of his elder son, Musa. In this year the Rus attacked to Azerbaijan lands with 38 ships. Musa made an agreement with them, “took them to Beylagan, where the population rose against him”. By the aid of the Rus Musa occupied Beylagan, captivated his brother Askariyye, executed him and restored the authority of Shaddadids in Beylagan.
The increasing of Fazl’s power and his fought for the lands of Shaki melikate and Kakhetia caused to the war between him and the tsars of Georgia, Bagrat III, Armenia, Gagik I and the emir of Tiflis, Jafar. In 1030 allied troops defeated Fazl, at the result of which “he fell sick” and died after the 47 years of ruling. After his death, his elder son Musa (1031-1034), then his grandson Ali Lashkeri II (1034-1049) came to the throne.
Lashkeri II concluded treaty with the governor of Tiflis, Jafar and aided him against the Georgian-abkhazian tsar, Bagrat III. According to the poems of Gatran Tabrizi, there happened two battles between Lashkeri II and Bagrat III and Lashkeri II won in both of them.
After the death of Lashkeri II his little son was in the reign for two months (1049-1050) and after him the authority of Shaddadids passed to the hands of the son of Fazl I, Abulsavar Shavur (1049/50- 1067), who was the governor of Dabil before this (1022-1049). In 1062, 200 years of Jafarids’ reign in Tiflis was ended, the settlers of Tiflis appealed to Shavur and requested him to occupy the power in the city.
But, the vezir who tried to avoid from the new war with neighborhood countries, dissuaded Shavur from this thought. In the same year, alanians attacked to Azerbaijan, “killed lots of people here, captivated 20 thousand men, women and children”. Due to prevent such invasions, Shavur built walls around the city and constructed moat in 1063. At the result of the fortification of the city, Shavur managed to prevent the attack of Abkhazian-georgian tsar, Bagrat IV (1027-1072), who relied on alanian troops, in the same year.
In 1065 the campaign of united troops of Bagrat IV and alanians was repeated. Moving from the West to the East in the direction of Ganja they killed lots of people, burnt villages but they were not able to capture Ganja.
After the death of Shavur (1067), his elder son Fazl, who was declared the heir of the throne even during Shavur’s ruling, came to the throne among his 5 sons (1067-1073). He was captivated by the Georgian tsar Bagrat IV, in the second year of his ruling. For a year, Ganja was governed by his second brother, but then Fazl I was released and he restored his power in the state of Shaddadids. It’s also important to mention that, Shaddadids accepted the vassal dependence under Turkish seldjukids empire, especially during Fazl I authority. Shaddadids utilized from this in their struggle against other South Caucasian governors. At the end of 60s and the beginning of 70s, Fazl attacked to the possessions of ShirvanShahs twice and enlarged his authority till Derbend. In 1073-1074s his son Fazlun rose against his father, kept Fazl in the castle of Charek and became the head of the state of Shaddadids. But after two years, i.e. in 1075 he changed with ceding to all territory of Shaddadids, including the capital city of Ganja to the Turkish army, led by Savtekim, who was appointed the governor of South Caucasus by the magnificent Sultan of Sedjukids, Melik-Shah. So, the state of Shaddadids in Azerbaijan was collapsed and its territory passed to the content of Seldjukids empire.