In order to make himself appear more important, a miller lied to a king, telling him that his daughter could spin straw into gold. The king called for the girl, shut her in a tower room with straw and a spinning wheel, and demanded that she spin the straw into gold by morning, for three nights, or be executed (other versions have the king threatening to lock her up in a dungeon forever).
She had given up all hope, when an impish creature appeared in the room and spun straw into gold for her in return for her necklace, then again the following night for her ring. On the third night, when she had nothing with which to reward him, the strange creature spun straw into gold for a promise that the girl's first-born child would become his.
Rumpelstiltskin is the eponymous character and antagonist of a fairy tale that originated in Germany (where he is known as Rumpelstilzchen).