Two years later he became the Qadi of Córdoba. In his free time he studied and wrote. In 1195, Averroes wrote a paper about how he thought philosophy was less than useful for the discovery of religious truth. He was disgraced and many of his papers were burned. The Caliph imprisoned Averroes and exiled him from the country. He lived in Lucena for a short time, then he was brought back by the Caliph to be a judge. He died in 1198.