It is said that the angels knew this would happen because of what they had already witnessed among those who inhabited the earth before Adam—the jinn and a race called the Bann. This was the view of Qatādah.
ʿAbd Allāh ibn ʿUmar added: “The jinn dwelt on earth two thousand years before Adam; they shed blood, so Allah sent an army of angels against them and drove them to the islands of the seas.” A similar report comes from Ibn ʿAbbās.
Al-Ḥasan said: They were simply inspired with that knowledge.
[Others maintained that the angels learned it from the Preserved Tablet: Hārūt and Mārūt showed it to them, having taken it from an angel above them named as-Sijill. This was narrated by Ibn Abī Ḥātim from Abū Jaʿfar al-Bāqir.]
Another opinion holds that the angels knew it because anything fashioned from earthly matter is, for the most part, disposed to such behaviour.
The angels continued, “We glorify You with praise and declare Your holiness” (al-Baqarah 2:30)—meaning, we worship You unceasingly and none of us disobeys You. If the purpose of creating these beings is that they worship You, here we are, never flagging night or day.
He replied, “I know what you do not know” (al-Baqarah 2:30)—that is, I know the overriding wisdom in creating them which you cannot yet grasp: prophets and messengers, the utterly truthful, martyrs, and the righteous will emerge from among them.
He then displayed Adam’s superiority to the angels in knowledge: “And He taught Adam the names of all things” (al-Baqarah 2:31).
Ibn ʿAbbās said: These are the names by which people recognise things—human, beast, land, plain, sea, mountain, camel, donkey, and the like among nations and otherwise. In another narration he added that Adam was taught the words for a dish, a cooking-pot, even for both the loud and the soft breaking of wind.
Mujāhid said: He taught him the name of every beast, every bird—indeed of everything; the same was affirmed by Saʿīd ibn Jubayr, Qatādah, and many others.
Al-Rabīʿ said: He taught him the names of the angels.
ʿAbd al-Raḥmān ibn Zayd said: He taught him the names of his offspring.
The soundest view is that Allah taught him the names of all entities and their actions, in both their large and diminutive forms, as Ibn ʿAbbās—may Allah be pleased with him—indicated.
Al-Bukhārī here cites, as does Muslim, the ḥadīth transmitted through Saʿīd and Hishām, from Qatādah, from Anas ibn Mālik, that the Messenger of Allah (peace and blessings be upon him) said:
“On the Day of Resurrection the believers will gather and say, ‘If only we could find someone to intercede with our Lord so that He may relieve us of this place.’ They will go to Adam and say, ‘You are the father of humankind; Allah created you with His own hand and made the angels prostrate to you…’”