Harthama was in Samarkand when al-Rashid died at Tus in March 809, and remained in the east after. Consequently he threw in his lot with al-Ma'mun (r. 813–833) in the civil war against al-Amin (r. 809–813), and was along with Tahir ibn Husayn one of the two commanders of al-Ma'mun's army during the crucial year-long siege of Baghdad in 812–813. During the siege he led the attack from the east while Tahir commanded from the west. In the final stage of the siege, Harthama tried unsuccessfully to secure the surrender and life of al-Amin, by sending a boat to ferry him over the Tigris. The boat, however, capsized, and al-Amin was captured and executed by Tahir's men.