The last battle between the Abbasid caliphate and the Khurrams occurred in Badd Fort on 837. The Khurramits were defeated, and Afšīn reached Badd Fort. After capturing Badd Fort, Babak went to near the Araz River. His goal was to join the Byzantine emperor, gather new forces and continue the struggle. Thus, it was announced that al-Mutasim would give a reward of two million dirhams to whoever handed Babak over alive. Babak's former ally, Sahl ibn Sumbat, handed Babak over to the Abbasids, and on March 14, 838, Babak was executed in the city of Samira.