Whenever a tree sprouted in front of him he would ask it, “What is your name?”
It would answer, “Such-and-such.”
He would then ask, “For what purpose are you?” If it was for cultivation it would be planted, and if it was for medicine it would be left to grow (1).
One day, while he was praying, he saw a tree before him and said to it, “What is your name?”
It replied, “Al-Kharrūb” (the carob tree).
He asked, “And for what purpose are you?”
It said, “For the ruin of this House.”
Solomon prayed, “O Allah, conceal my death from the jinn so that mankind may know that the jinn do not know the unseen.” He fashioned that tree into a staff and leaned upon it for a whole year while the jinn continued to work. A termite then gnawed through it, and mankind realized that had the jinn known the unseen they would not have remained a year in the humiliating punishment (2).
He said: Ibn ʿAbbās used to recite the verse in that very way as well (3). He also said: The jinn showed gratitude to the termite and would bring it water.
This is the wording reported by Ibn Jarīr (4). In the narration of ʿAṭāʾ ibn al-Sāʾib (5) there is some objectionable content (6).
Al-Ḥāfiẓ Ibn ʿAsākir also transmitted it through Salamah ibn Kuhayl—from Saʿīd ibn Jubayr—from Ibn ʿAbbās—as a mawqūf report (7), and that version is closer to what is correct. Allah knows best.
Al-Suddī reported—on the authority of Abū Mālik, Abū Ṣāliḥ from Ibn ʿAbbās, Murrah from Ibn Masʿūd, and a group of Companions—that Solomon, peace be upon him, would seclude himself in the Temple for one or two years, or for a month or two, or for shorter or longer periods, taking his food and drink inside with him. He did so on the occasion when he passed away. It began with the fact that every morning a tree would sprout in the Temple, and he would come to it and ask, “What is your name?” The tree would reply, “My name is such-and-such.” He would then ask, “For what reason have you sprouted?” It would say, “I have sprouted for such-and-such,” whereupon he would order it to be cut down (8). If it had sprouted to be planted, he would plant it, and if it had sprouted for medicinal purposes (9) it would say, “I have sprouted as a remedy for such-and-such,” and he would leave it for that purpose.
Then a tree called al-Kharrūbah sprouted. He asked it, “What is your name?”
It replied, “I am al-Kharrūbah.”
He said, “And for what purpose—”