Elegast (elf spirit) is the hero and noble robber in the poem Karel ende Elegast, a Medieval Dutch epic poem that has been translated into English as Charlemagne and Elbegast. In the poem, he possibly represents the King of the Elves. He appears as a knight on a black horse, an outcast vassal of Charlemagne living in the forest. The original Dutch poem uses the name Elegast, while translated versions of the poem commonly use the name Elbegast in German and English, or Alegast in the Scandinavian ballad.
Karel ende Elegast was an original poem in Dutch that scholars think was probably written at the end of the 12th century, otherwise in the 13th century and set in the region of Charlemagne's castle in Ingelheim. It is a Frankish romance of Charlemagne ("Karel") as an exemplary Christian king who was led on a strange quest to be a robber.
Although the poem does not describe Elegast's background, he was an old friend of Charlemagne that had fallen into disgrace, and his banishment to the forest and his name connotes he was elven. Elegast could put people to sleep magically, could open locks without keys, and has a magic herb that when he puts in his mouth allows him to talk to animals. He lived in the forest, thief to the rich people and kind to poor people.
In summary, Charlemagne has a heavenly vision to go thieving in disguise, so meets with Elegast in the forest at night. Elegast does not recognize the king, as Charlemagne is in disguise as a thief. When Charlemagne suggests they steal from the king's castle, Elegast proves his loyalty to Charlemagne by refusing to steal from the king. Instead, Elegast takes Charlemagne to burglarize the castle of Charlemagne's brother-in-law, Eggeric van Eggermonde. Once they break into the castle, Elegast overhears Eggeric scheming to kill Charlemagne to his wife, who is Charlemagne's sister. In this way Charlemagne learns of a traitor in his court. The next day, when Eggeric arrives in Charlemagne's court, Charlemagne has Eggeric searched and finds his weapons. Elegast duels with Eggeric and exposes him as a traitor. Eggeric is therefore killed, and his wife is given in marriage to Elegast. Elegast's reputation is also restored in the Charlemagne court.
The names Elegast and Alegast and Elbegast, are variants of the same Germanic name, as it were Common Germanic *albi-gastiz, composed of the well attested elements *albi- "elf" and *gastiz "guest, spirit, being".