Hafs ibn al-Walid ibn Yusuf al-Hadrami

Hafs ibn al-Walid ibn Yusuf al-Hadrami was a governor of Egypt for the Umayyad Caliphate in the mid-8th century.

Hafs was a member of a well-connected family from the original Arab settler community in Egypt —the "jund", chiefly resident at the capital of Fustat, which dominated the province's administration.

He had served as sahib al-shurta (chief of police) prior to his rise to the governorship. With the death of Caliph Hisham ibn Abd al-Malik in 743, the Umayyad regime entered a period of instability—that eventually culminated in civil war—and Hafs sought to use the weakness of the Umayyad government to re-affirm the predominance of the jund in Egyptian affairs against the Qays Syrians who had come to Egypt with Umayyad backing over the previous years. The Syrians were forcibly expelled from Fustat, and Hafs set about recruiting a force of 30,000 men, named Hafsiya after him, from among the native non-Arab converts ("maqamisa" and "mawali"). When the pro-Qays Marwan II rose to the throne in 744, Hafs resigned and the new Caliph ordered his replacement with Hasan ibn Atahiya and the disbandment of the Hafsiya.

The Hafsiya however refused to accept the order to disband and mutinied, besieging the new governor in his residence until he and his sahib al-shurta both were forced to leave Egypt. Hafs, though unwilling, was restored by the mutinous troops as governor. In the next year, 745, when Marwan dispatched a new governor, Hawthara ibn Suhayl al-Bahili, at the head of a large Syrian army. Despite his supporters' eagerness to resist, Hafs proved willing to surrender his position. Hawthara took Fustat without opposition, but immediately launched a purge, to which Hafs and several Hafsiya leaders fell victim.