 Ibn Abi Amir was treasurer of the household of the caliph's wife and children, director of the mint at Madinat al-Zahra, commander of the Cordoba police, and qadi of the frontier.During his time as qadi in north Africa, Ibn Abi Amir developed close ties with the North African Berbers.On the death of Al-Hakam II, the heir Hisham II was underage, and the position of hajib was occupied by a Berber named al-Mushafi.