 In 835, Caliph al-Mu'tasim appointed Afshin as governor of Adharbayjan to fight against Babak Khorramdin, leader of anti-Islamic neo-Mazdakite Persian movement of the Khurramites.After a fierce resistance by Babak's army, Afshin eventually defeated it and captured Babak's castle of Bazz in August 837.Ya'qubi (Tarikh II, 579) records Afshin freeing 7,600 Arab prisoners from this fortress and he destroyed the castle.