The Quran explicitly states that their deeds were the cause of this, as in His words:
“When they provoked Our anger, We took vengeance upon them.”
[Surah al-Zukhruf: 55]
And His words:
“That was because they followed what angered Allah and detested His pleasure, so He rendered their deeds worthless.”
[Surah Muhammad: 28]
And His words:
“Say: If you love Allah, then follow me, and Allah will love you.”
[Surah Āl Imrān: 31]
There are other examples of this as well.
Indeed, it is established in the two Sahih collections (1), in the hadith of intercession, that each of the messengers will say:
“Today my Lord has become angry as never before and never again.” (2)
It is also related in the two Sahih collections from Zayd ibn Khālid, who said:
“The Messenger of Allah—may Allah bless him and grant him peace—led us in the dawn prayer following rain that had fallen during the night. When he turned around after the prayer, he asked (3), ‘Do you know what your Lord said last night?’
“We replied, ‘Allah and His Messenger know best.’
“He said, ‘He said: “This morning, some of My servants believed in Me while others disbelieved in Me. Whoever said, ‘We were given rain by Allah’s grace and mercy,’ believes in Me and disbelieves in the star. But whoever said, ‘We were given rain because such-and-such a star rose,’ disbelieves in Me and believes in the star.”’” (4)