The Exempla of the Rabbis preserves a sprawling collection of tales about Solomon and the power of the divine Name. In these stories, Solomon commands demons, builds the Temple without iron tools using the miraculous Shamir worm, and outwits Ashmedai, the king of demons, only to be outwitted in return.
The most famous episode tells how Solomon tricked Ashmedai into revealing where the Shamir could be found. But Ashmedai, once freed from his chains, hurled Solomon four hundred parasangs away and took his throne. For years, Solomon wandered as a beggar, telling anyone who would listen, "I am Kohelet — I was king over Israel in Jerusalem" (Ecclesiastes 1:12). No one believed him.
The cycle also includes tales of Solomon's wisdom in judgment, his ability to understand the speech of birds and animals, and the legendary wealth that flowed through his kingdom. These stories appear across the Talmud (Gittin 68a-b), Targum Sheni to Esther, and various collections of medieval Jewish folklore.