In July 903, al-Muktafi decided to personally campaign against the Qarmatians, and left Baghdad for Raqqa at the head of the army. While al-Muktafi remained at Raqqa, actual command was given to the head of the department of the army ("dīwān al-jund"), Muhammad ibn Sulayman al-Katib. Other Abbasid forces, under Badr al-Hammami and al-Husayn ibn Hamdan, also operated against the Qarmatians, defeating them near Damascus. On 29 November 903, near Hama, Muhammad ibn Sulayman came upon the main Qarmatian army and routed it, capturing or killing its main leaders and dispersing their troops. Al-Muktafi returned to Baghdad with the senior captives, who were thrown into prison. Muhammad ibn Sulayman remained at Raqqa to scour the countryside and round up the remaining rebels. He too then returned to Baghdad, which he entered in triumph on 2 February 904. Eleven days later, on 13 February, Muhammad and the "sahib al-shurta" (chief of security) of the capital, Ahmad ibn Muhammad al-Wathiqi, presided over the public execution of the Qarmatian leaders and Qarmatian sympathizers rounded up from Kufa and Baghdad.