Harthama ibn A'yan had been in Samarkand when al-Rashid died at Tus in March 809, and remained in the east after.
Consequently he had thrown in his lot with al-Ma'mun in the civil war against al-Amin, and is along with Tahir ibn Husayn one of the two commanders of al-Ma'mun's army during the crucial year-long siege of Baghdad.
During the siege Harthama leads the attack from the east while Tahir commands from the west.
In the final stage of the siege, Harthama tries unsuccessfully to secure the surrender and life of al-Amin, who has in the meantime been declared deposed as caliph in Iraq and Arabia, by sending a boat to ferry him over the Tigris.
The boat, however, capsizes, and al-Amin is captured and executed by Tahir's men, contrary, it seems, to al-Ma'mun's orders, on September 24 or 25, 813.
The father of Hassan ibn Sahl was an Iranian Zoroastrian convert to Islam.
Along with his brother, the future vizier al-Fadl ibn Sahl, Hasan had entered the service of the Barmakid al-Fadl ibn Yahya in the reign of Harun.
During the civil war, he has been entrusted with the supervision of the land tax (kharaj) office.
After Ma'mun's troops capture the caliphal capital, Baghdad, Hasan is sent west to assume the governance of Iraq, while Ma'mun and Fadl remain in Marv.
Al-Ma'mun rules from 813 as the recognized caliph, but Egypt, Syria, and Mesopotamia begin to slip from central control.