lost. Although Ibn Khazar managed again and again to escape his hunters, in March 928 al-Qa'im sacked the Zenata capital, Zabraqa. The victorious army then returned to Tahert and thence Ifriqiya, being given a triumphal reception at Mahdiya in November 928. His victory dispatch prompted the circulation of a poem, where the al-Qa'im announces himself as the "Son of the Messenger of God" who is about to "roam throughout God's earth...to Egypt and Iraq, and afterwards I shall concern myself with Baghdad". Despite this success, Fatimid rule over the remote areas of the Maghreb was fragile. Even in Tahert, the local population felt at liberty to nominate their own governor, Masala's son Ali, when Yasal died in 931. Al-Mahdi hat to sent a military expedition to the city to install his preferred candidate, Yasal's son Hamid. Rivalry with Córdoba Apart from the Abbasids, al-Mahdi faced a major Muslim rival closer to Ifriqiya, in the form of the Umayyads of Córdoba, rulers of al-Andalus (Islamic Spain). However, the confrontation between the two major Islamic powers of the western Mediterranean took place mostly via propaganda and proxies, rather than direct conflict. At the time of al-Mahdi's accession, the Umayyad emirate was plagued by internal dissension, notably the uprising of Ibn Hafsun, who in his conflict with Emir Abdallah () pledged his allegiance to al-Mahdi. Al-Mahdi sent robes of honour and two Isma'ili s to the rebel leader, in whose territories the Friday sermon was read in the name of the Fatimid caliph. Al-Mahdi's campaigns in the western Maghreb, in what is now Morocco, were in part meant to "spread fear on the threshold of the Iberian Peninsula", according to historian Farhat Dachraoui, but the restiveness of the Berber tribes limited the ability of the Fatimid ruler to project power beyond Tahert and seriously contemplate an invasion of al-Andalus. Nevertheless, the Fatimid threat was taken seriously by the Umayyad emir Abd al-Rahman III (), who reinforced his fleet and established patrols along his southern coasts as one of his first measures upon his accession. During the first two decades of his rule, Abd al-Rahman was occupied with suppressing revolts, most notably that of Ibn Hafsun; but as his power grew, in 927 an Umayyad fleet captured Melilla, establishing it as a military base in the Moroccan coast, followed by Ceuta in 931. Abd al-Rahman also entered into an alliance with Ibn Khazar, recognizing