Abu Hafs was the grandson of the famous emir Umar ibn Abdallah al-Aqta (his name is also transcribed as Amr ibn Ubaydallah), who was the ruler of the city of Malatya from the 830s until his death at the Battle of Lalakaon in 863. Under Umar, Malatya had been one of the most important emirates on the border zone ("thughur") between the Abbasid Caliphate and the Byzantine Empire, and Umar himself had been one of the most active Muslim leaders in the perennial raids and counter-raids that characterized the Arab–Byzantine wars. The disastrous defeat at Lalakaon, however, shattered Malatya's power, and signalled the beginning of a gradual Byzantine advance in the borderlands. Over the next few decades, the emirate's Paulician allies and their principality at Tephrike were defeated and annexed, and a string of fortresses, often manned by Armenians, occupied the hill country around the city. From 927 on, with their other frontiers secure, the Byzantines, under the leadership of general John Kourkouas, concentrated their resources against the Arabs. First attempts to capture Malatya in 927 and 928 failed, but Byzantine troops, based on the fortresses surrounding the city, repeatedly ravaged its countryside and cut it off from assistance.