After a few years, Averroes returned to court in Marrakesh and was again in the caliph's favor. He died shortly afterwards, on 11 December 1198 (9 Safar 595 in the Islamic calendar). He was initially buried in North Africa. His body was later moved to Córdoba for another funeral, at which future Sufi mystic and philosopher ibn Arabi (1165–1240) was present.