This spear was forged by the dwarves who were friends of Loki. Loki attempted to win back the favor of the Aesir after he cut off Sif's beautiful hair. The dwarves who dwelt in Svartheim were glad to help Loki's cause, and showcase their fine craftmanship.
The dwarves created three gifts for the Aesir:
A spun-gold wig for Sif that grew like normal hair when it was placed on her head.
A spear named Gungnir that was so well-balanced that it could hit any mark regardless of how poorly it was thrown.
A boat named Skidbladnir that could sail on any ocean, but could be folded up and placed in one's pocket.