Maslama served loyally under Amr ibn al-As, who was governor of Egypt until his death in January 664, but remained on the sidelines under his two successors, Utba ibn Abi Sufyan and Uqba ibn Amir. Finally, in 667/8, Maslama himself petitioned Mu'awiya ibn Abi Sufyan, now Caliph, and was appointed governor of Egypt. He held the post until 670 according to al-Tabari, though other sources report that he governed the country continuously until his death on 9 April 682. Little is known of is tenure, except that he was active in the wars against the Byzantine Empire, sending regular expeditions against them, and rebuilt the Mosque of Amr ibn al-As in Fustat, to which he added minarets. Otherwise his period of office seems to have been one of domestic tranquility. Some sources claim that Maslama was also responsible for the Muslim campaigns in Ifriqiya and the Maghreb in general, although others insist that these areas did not come under his authority until ca. 675; at any rate, he replaced Uqba ibn Nafi, who had been in charge in Ifriqiya until then, with Abu al-Muhajir Dinar in 671 or in 675.