Born in Guadix, near Granada, he was educated by Ibn Bajjah (Avempace). His family were from the Arab Qays tribe. He was a secretary for several leaders, including the rulers of Ceuta and Tangier, in 1154. He also served as a secretary for the ruler of Granada, and later as vizier and physician for Abu Yaqub Yusuf, the Almohad caliph, to whom he recommended Ibn Rushd (Averroës) as his own future successor in 1169. Ibn Rushd later reports this event and describes how Ibn Tufayl then inspired him to write his famous Aristotelian commentaries: