During Babek’s leadership the centre of Khurramid movement continued to be the castle of Bazz. At the beginning of uprising, Arabs, living around the castle of Bazz were beaten and departed. As the leader of the movement, Babek has already showed his worth. His people, extended in all regions of the country called people to join to their liberation fought and to create voluntary troops. Soon, the number of horsemen troops, which constituted from peasants, craftsmen and urban poor reached to 20 thousand. Except of them, as it was mentioned above most part of local feudals, even the prominent statesmen of Caliphate participated in liberation war till the year of 830. Among them we can mention the names of Tabaristan, Mezyar, emir of Mingindjar, governor of Merend, Ismu al-Kurdi, governor of South Caucasus, Khatim ibn Kharsan, who did his best to separate from Caliphate.
The troops of Caliphate did not encounter with khurramid in big battles till the year of 819 and caliph palace did not consider this movement strict one. But the first achievements of rebellors and liberation of lots of regions by them obliged caliph al-Mamun (813-833) to direct regular army against Khurramids under the leadership of Yahya ibn Muzin. This army was destroyed and dispersed. In 821, one of the biggest Arabic feudals, Savada ibn Abdulhamid utilized from vague circumstances and attacked to Syunik. Governor of Syunik, Vasak appealed to Babek for help. Troops, sent by Babek overwhelmed and drove Savad away. After the death of Vasak, Babek married to his daughter and occupied the regions of Syunik, Beylagan, Arsakh and Uti.
Subsequent decade (821-830) brought significant military victories to Babek: In 821, khurramids destroyed caliph army, led by the governor of Azerbaijan, Isa ibn Muhammed near the city of Barda; in the year of 823/824 Babek destroyed another army of Caliphate and captivated its commander, Ahmed ibn Cuneyda. Barda, Ardebil, Nakhichevan , Beylagan and Shirvan were liberated. Babek’s comrades in arms, such as Asim, Tarkhan, Rustem, Muaviyya, Abdulla also participated in all battles. Babek appointed his comrade, Rustam the governor of Arran. In one of significant and essential battles happened between khurramids and Arabic army in 828, there were destroyed 30 thousand Arabic troops, led by Muhammed ibn Hamid at-Tusi. Babek besieged Arabs near Maragha and destroyed this army. Ibn Hamid was killed and his army was defeated. The subsequent battle that took place in 829/830 was the fifth deefeat of Caliphate.
As the governors, appointed by caliph couldn’t attain to overcome khurramid movement, Arabic administration had to rapidly change them. Only in 829, there were changed four valies in Azerbaijan: Ibrahim ibn al-Loys, Abdulla ibn Tahir, Ali ibn-Khitam, Udjayer ibn Anbasan.
In 830, troops of Khurramids captured Hamadan, which deprived Caliphate from major strategic and transit ways, connected this state with eastern lands. Due to fight with Caliphate in unit, Babek set relations with Byzantine emperor. According to al-Masudi, Babekid movement scarcely collapsed the Abbasid reign. Understanding this danger, Caliph al Mutasim concluded treaty with Byzantine and then concentrated all his powers against Babek. Usrushan Turk, Afshin Haydar ibn Kabus was appointed to the commander of Arabic army. Afshin became prominent during Arabic-Byzantine wars.
Simultaneously, at that time, i.e in 830/831 Beylagan ians, headed by Davan and Shapukh rose against Babek and killed his supporter, the governor of Arran-Stepannos Ablasad. Although Beylagan ians could capture several regions of Uti and Arsakh, local governor Esai Abu Musa withdrew them by the aid of Babek. Neverthless, later the relations between Babek and local Albanian feudals began to weaken; such feudal as Sahl ibn Sumbat, Esai Abu Musa and other albanian princes separated from Khurramids, since they did not like Babek’s intercession to peasants, his desire to reconcile them with feudals, his interference to Albanian properties and not accepting “advice” from them.
Military achievements of Khurramids deeply disturbed administrative circle of Caliphate. The existence of Caliphate was under dengeour and this was obviously noticed in the works of Arabic authors, who openly expressed their dislike to Khurramids as well as support of interests of Caliphate. At-Tabari writes: “unexpected victory of khurramids brought the caliph to horror”, according to Dinavari “Activity of Babak enlarged and they began to be afraid of him.
Commanders fought with him but they could not win, Babak destroyed troops and killed the commenders”. Al Kindi informed that, “this war brought to our master and caliph Amir al-Mumin great dengeour and disturbance”. And Masudi (died in 956) writes: “The work of Babak increased to an unexpected amount, his influence was strengthened, the number of his army was so increased that he scarcely destroyed Abbasid dynasty”.
At the result of the caliph Al-Mamun’s death in 833, there were arisen uprisings in Isfahan, Fars, Kuhistan. Before his death Al-Mamun gave his tastement to the future caliph, to his brother Al-Mutasim. The main arrangement of this tastement was the order to concentrate all power of Caliphate to the war with khurramids. “And about khurramids wrote al-Mamun-send decisive and cruel man to the war against them, patiently helped him with money, guns and troops. If the war continued direct go against them yourself with your close people.” After coming to the throne, al-Mutasim immediately began to strict preparation of the war with khurramids. First of all, new caliph ended military actions against Byzantine and utilized from 4 years (833- 837) break for mobilization of his power against Babek and for preparation of material-financial provision of his army. Then he implemented the order of his brother and achieved the change during the war. Abu-Said Muhammed, who was sent to Azerbaijan with a new army attained to overcome Khurramids in the winter of 833, near Hamadan region. At the result of this victory, he could restore information centre and all castles in the way from the capital Samarra till Zancan and Ardebil. In this cruel war the troops of Khurramids were destroyed. The initiative also passed to the hands of Caliphate military commanders.
Babek understood all these events and that’s why he began to correspond with Byzantine emperor, Teofil. In one of his letters Babek wrote that the caliph sent all his army against khurramids and if the emperor wanted to attack to Caliphate, then nobody would encounter him. Although, Teofil attacked to Arabic lands with 100 thousand army and captured the city-castle of Zibatru and some other castles, this did not give any facilitation to Babak.
The happened change in liberation war was not casual. The war, led by Babek approximately 20 years was unequal and cruel, it was arisen against the biggest empire of early medieval phase, which exploited the wealth of subordinated countries more than two hundred years and which utilized all her military and financial potential against Babek and Khurramids.
There were also happening changes inside of Khurramid movement. The slogan about returning lands to rural community was disliked by local feudals, who jointed to this movement. By the order of caliph, Arabs inclined such people into their side, learnt the secrets of Khurramids from them and in consequence stroke these rebellors.
In 835, capable military commander from Turkish origin, Afshin Haydar ibn Kavus was appointed the head of Arabic army. This commander showed himself in the best side during the war against Byzantine, conducted in Azerbaijan and Egypt. Afshin was eager to press Khurramid movement rapidly and he moved against rebellors with his amount of 10 thousands Turkish garrison. His assistant, Bugha at Turkish side also aided with five thousands troops.
In 836, Babek destroyed the troops of self-confidence Bugha, who thought to overcome Babek sole, on the foothills of the mountain of Hashdadsar: khurramids pursued Arabic troops and suddenly Babek attacked to them with his two thousandth troops. Bugha could hardly escape. It was the last achievement of Babek. The power of Khurramids was exhausted.
In the summer of 837, Afshin besieged the castle of Bazz. Arabic commanders promised Babek forgiveness by the caliph Al-Mutasim, but he rejected such suggestion. Babek replied to the letter of his elder son, who was captived by Afshin and offered to his father to surrender in such words: “You are not my son. It’s better to live as a leader for one day than a slave for forty years” Soon, the soldiers of caliphate entered to the castle and the city was captured by Arabic troops on August 26, 837. Afshin ordered to destruct forts and burn the castle in three days. Neither of forts, nor houses were kept, he destroyed all of them. According to the sources during the capturing of Bazz, more than 80 thousand khurramids were killed, 7600 khurramids, including Babek’s sons and his family members were captivated. Babek, his brothers Abdullah and Muaviyya, his last wife, the daughter of Syunik governor – Ibnat Kalandaliye and his mother could hide in the place, which lied to Arran through the river Araz.
Babek sent message to one of his former ally, Sahl-ibn Sumbat (Albanian governor). When Sahl learnt the location of Babek and his family he decided to surrender Babek to Arabs – appointed 1 million dirham to the head of Babek and promised privileges attracted him. Sahl came to Babek, kissed his hand and called himself the slave of Babek.
Sahl brought Babek to his castle and immediately sent his horseman to the camp of Afshin. So, Arabic soldiers captured Babek. Sahl received the promised million dirham, also Afshin rewarded him with the big tie, with great diamond on it and the crown. Sahl’s son, who participated in the action also received the award of one million dirham. Soon Abdullah, Babek’s brother was also brought. Namely Babek noticed the location of his family during his speech with Sahl.
Afshin brought Babek to Samarra. After a brief inquiry, on March 14, 838 Babek was quartered (i.e. executed), then his head, hands and feet were chopped, the head of Babek was crammed in his stomach and he was burned. His brother was executed in such way. Before the death Babek was coregous and did not beg forgiveness from the caliph. After the execution of Babek his head was sent to Khorasan and body was kept in Samarra in order to frighten the population. Arabic author al Mukaddasy wrote gladly that, victory over Babek was the greatest victory of Islam and his captivation and assosination was the holiday for all Muslims. But other medieval sources fairly mentioned that, “Babek was the hero of its time, whom the Caliphate was scared”. The historical importance of popular liberation fights in Azerbaijan, led by Babek is great. Although the Khurramid movement was pressed, it had significant trace and consequence for Azerbaijanis and other nations, which were subordinated to the Caliphate. This liberation movement, lasted more than twenty years engrossed great forces and means of Caliphate and played an important role in weakening of mignificant Arabic empire. At the result of these losses Caliphate couldn’t preserve its interior stability and couldn’t succeed to step unbreakable uprisings of other conquered countries. Khurramid movement became the one of factors, which prepared the release of Azerbaijan and other neighbourhood countries from the subordination of Arabic supremacy in the second half of the 9th century.