Grundtvig's lyrics, loosely based on the 14th Century Latin hymn "Puer, natus in Bethlehem", were first published in the magazine "Nyeste Skilderie af Kjøbenhavn", December 23, 1820.
It was set to the music of a traditional German melody from around 1600, which A.P. Berggreen revised in 1849.