The Byzantine and Arabic sources agree that Abu Hafs was the leader of a group of refugees from
al-Andalus, who landed on the island of
Crete and conquered it. Traditionally these Andalusis have been described as the survivors of against the emir
al-Hakam I of
Córdoba in 818. In the aftermath of its suppression, the citizens of the Córdoban suburb of al-Rabad were exiled
en masse. Some settled in
Fez in
Morocco, but others, numbering over 10,000, took to piracy, probably joined by other Andalusis, landed in
Alexandria and took control of the city until 827, when they were besieged and expelled by the
Abbasid general
Abdullah ibn Tahir al-Khurasani. As W. Kubiak points out, however, the supposed origin from Córdoba is contradicted by other sources, which record the presence of Andalusi corsairs in Alexandria as early as 798/9, and their takeover is dated to 814; furthermore, Abu Hafs, who is recorded as their leader, came from a locality (, now
Los Pedroches) that was far from Córdoba. Furthermore,
Ibn Hayyan reports that the initial leader of the refugees was not Abu Hafs, but Muhajir ibn al-Qatil. He is echoed by
Ibn Sa'id, who also adds that a certain Yahya, leader of the
faqihs of Córdoba who had joined the exiles of Rabad, was another leader. It thus appears that Abu Hafs may have become the leader of the Andalusis at Alexandria, for it is only here that he is explicitly named as the leader of the
Rabaḍiyyūn, the "rebels of Rabad", by
Ibn Khaldun and
al-Maqqari. ==Conquest of Crete==