Ages ago, an unimaginably powerful cosmic storm called the God Tempest approached Asgard. Called the "Mother of Thunder," the storm possessed the power to knock planets out of their orbit and make black holes shake. Odin, chief of the Norse gods, battled the storm for many days when it threatened Asgard. Once the storm was weakened enough, Odin defeated the God Tempest by trapping it into a chunk of Uru that was given to him by the Dwarves of Nidavellir as a gift.
From the Uru, Odin ordered the Dwarves of Nidavellir to forge Mjölnir. The blacksmiths Eitri, Brokk, and Buri needed to use the tremendous heat of a star to get the forge hot enough to smelt the Uru. The hammer was completed in seventeen weeks.
In the process the star exploded and almost took Midgard with it; that event may explain the extinction of the dinosaurs, about 65 million years ago.
When Odin first tried to wield Mjölnir, he couldn't control it due to the God Tempest still retaining its power. The hammer devastated Asgard as it flew out of control. Out of spite, Odin cast an enchantment on the hammer to prevent anyone else from wielding the hammer. The hammer was stored away where it sat for untold ages where the God Tempest would eventually die, but its power would remain inside Mjölnir.
Although powerful in and of itself, the hammer also received several potent spells from Odin, who slew the Frost Giant Laufey with it.
Much later, Mjölnir was bequeathed to Thor, after he proved himself worthy through several trials.
With few exceptions, Thor has carried Mjölnir throughout his adventures. Thus, the history of Mjölnir follow the history of Thor. Although Asgard was destroyed in Ragnarök, Thor, and thus the hammer, survived.
After Nick Fury told him an undisclosed secret, he lost his ability of wielding Mjölnir.
Later, a woman became Mjölnir's new wielder and the new Thor. She was eventually revealed to be Thor's ex-lover Jane Foster.