In order to make himself appear more important, a miller lied to the king 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. She had given up all hope, when a dwarfish 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 firstborn child would become his.
The king was so impressed that he married the miller's daughter, but when their first child was born, the dwarf returned to claim his payment: "Now give me what you promised". The queen was frightened and offered him all the wealth she had if she could keep the child. The dwarf refused but finally agreed to give up his claim to the child if the queen could guess his name in three days. At first she failed, but before the final night, her messenger discovered the dwarf's remote mountain cottage and, unseen, overhears the dwarf hopping about his fire and singing. While there are many variations in this song, the 1886 translation by Lucy Crane reads:
- "To-day do I bake, to-morrow I brew,
- The day after that the queen's child comes in;
- And oh! I am glad that nobody knew
- That the name I am called is Rumpelstiltskin!"
When the dwarf came to the queen on the third day and she revealed his name, Rumpelstiltskin lost his bargain. In the 1812 edition of the Brothers Grimm tales, Rumpelstiltskin then "ran away angrily, and never came back". The ending was revised in a final 1857 edition to a more gruesome version where Rumpelstiltskin "in his rage drove his right foot so far into the ground that it sank in up to his waist; then in a passion he seized the left foot with both hands and tore himself in two." Other versions have Rumpelstiltskin driving his right foot so far into the ground that he creates a chasm and falls into it, never to be seen again. In the oral version originally collected by the Brothers Grimm, Rumpelstiltskin flies out of the window on a cooking ladle (Heidi Anne Heiner).