Ibn al-Khatib
In Granada, Ibn Khaldūn quickly came into competition with Muhammad's vizier, Ibn al-Khatib, who viewed the close relationship between Muhammad and Ibn Khaldūn with increasing mistrust. Ibn Khaldūn tried to shape the young Muhammad into his ideal of a wise ruler, an enterprise that Ibn al-Khatib thought foolish and a danger to peace in the country. History proved al-Khatib right, and at his instigation, Ibn Khaldūn was eventually sent back to North Africa. Al-Khatib himself was later accused by Muhammad of having unorthodox philosophical views and murdered despite an attempt by Ibn Khaldūn to intercede on behalf of his old rival.