Riyad as-Salihin (The Meadows of the Righteous)
by Imam Nawawi
279. Chapter: On the prohibition against boastfulness and arrogance
Allah says, "So do not claim purity for yourselves. He knows best those who have fear of Him," (W53:31; H53:32)
and the Almighty says, "There is only something against those who wrong people and act as tyrants in the earth without any right. Such people will have a painful punishment." (W42:39: H42:42)
1589. 'Iyad ibn Himar reported that the Messenger of Allah, may Allah bless him and grant him peace, said, "Allah Almighty has revealed to me that you should be humble in such a way that no one is either overbearing or boastful towards another person." [Muslim]
1590. Abu Hurayra reported that the Messenger of Allah, may Allah bless him and grant him peace, said, "When a man says, 'The people are destroyed,' then he is of all of them, the most destroyed.'" [Muslim]
This prohibition is when the person says this out of arrogance and to demean the people and show his elevation over them. This is what is unlawful. If he says it because of the lack of practice of the deen which he sees in people and says it out of sorrow for them and for the deen, there is no harm in it. That is the explanation of the scholars. The notable scholars who said that include Malik ibn Anas, al-Khattabi, al-Humaydi and others. I dealt with it in Kitab al-Adhkar.