In early October 749 (132 AH), Abu al-'Abbās as-Saffāh's rebel army entered Kufa, a major Muslim center in Southern Iraq. As-Saffah had not been yet declared caliph. One of his priorities was to eliminate his Umayyad rival, caliph Marwan II. The latter was defeated in February 750 at a battle on the (Great) Zab river north of Baghdad, effectively ending the Umayyad caliphate, which had ruled since 661 AD. Marwan II fled back to Damascus, which didn't welcome him, and was ultimately killed on the run in Egypt that August.