All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Abu Hamid al-Gazaali was a scholar and jurist of Muslims even though he was a leader of the Ashairah and head of the Sufi. He was also a philosopher and logician though he later wrote a book against philosophy. One of his known students Abu Bakr al-‘Arabisaid: ‘Our Shaykh first swallowed philosophy then he tried to vomit it but he could not do so.’
Al-Gazali wrote many books, some of which contained useful material and others did not. Shaykh Abu Umar ibn al-Salah said: ‘His books contain deviated matters, which the scholars of his school of Fiqh did not agree with.”
Imam ath-Thahabi wrote about his books that they contained many afflictions, which could not be cured.
Ath-Thahabi also wrote about his known book Ihyaa’ ‘Uloom Ad-Deen (The revival of Religious Sciences). ‘There are many weak Ahadeeth in this book. If this book did not contain traditions and etiquettes of Sufism and philosophers, it would be considered a good book.’
Ath-Thahabi wrote in his biography 'may Allaah have mercy upon Al-Gazaali; now where is a person similar to him? But we do not claim that any person could be free from committing mistakes or errors. Following a person in his mistakes is not permissible.
Therefore, a Muslim could derive benefits from his books, especially in Fiqh and Usool ul-Fiqh avoiding his mistakes. On the other hand, beneficial knowledge is always an objective of the Muslim, so he should accept it regardless of its source.
Allah knows best.