A very slightly updated version of the traditional Norwegian folk tale from Andrew Lang's Blue Fairy Book from 1889. The Blue Fairy Book was the first of 12 Fairy Books to be written and published in the late nineteenth and early twentieth centuries and, though Lang is credited as the creator of these books, it is worth noting that almost all of the actual translation and writing of the stories was done by others - most notably his wife, Nora.
This story is classified as ATU 425A in the ATU tale type classification system, which is the “Search for the Lost Husband” type.