The story of howMjöllnircame into existence is told in the tale ofThe Creation of Thor’s Hammer. To briefly summarize:
One day, the tricksterLokiwas feeling especially “tricksy,” and cut off the long, golden hair of Thor’s wife, Sif. Enraged, Thor was about to kill Loki when the latter swore to go down toSvartalfheim, the land of thedwarves, who were renowned as the greatest smiths in all of theNine Worlds. There he would obtain a head of hair for Sif that was even more marvelous than the one he had lopped off. Thor consented to this plea bargain.
While in the cavernous smithies of the dwarves, Loki was able to acquire his prize, and, by cunningly challenging several dwarves to prove who was the best smith, he acquired several more treasures for the gods as well. Among these was Thor’s hammer, which was short in the handle because Loki, in the form of a fly, bit the eyelid of the dwarf who was forging it.
When Thor saw the hammer, the finest weapon in the universe despite its flaw, he agreed to let Loki live.