Valley of the ants

Valley of the ants is a medieval Jewish legend about Solomon that is retold in the Jewish Encyclopedia and in Quran 27:18-19.

Talmud
In the legend, as retold in the Jewish Encyclopedia, Solomon rides on a magic carpet over a valley of ants that speak to him. This legend is based on the Tanakh mentioning Solomon's wealth, wisdom, and dominion over all creatures. The legend may also be based on the Book of Proverbs, which rabbinic Judaism traditionally ascribes to Solomon, mentioning ants as exemplars of morality. Of all the legends about Solomon's dominion over all creatures, the valley of the ants is the best known one among Jews.

Islam
The Quran mentions Solomon. The Jewish legend as compared to the one in the Quran are different except for the warning given by the queen ant, which is almost identical in both retellings regardless of the English translation of verse (āyah) eighteen.