On old miller can before the King and told him that his daughter could spin straw into gold. The King ordered her to be locked in a room and if she succeeded he would marry her but if she failed she would be killed.
She knew she couldn't spin straw but she didn't want to be killed. While she was crying this little man with a gray beard appeared beside her, he said that he could do it for her but for something in return.
She agreed and he spun all the straw into gold. The first night she gave him her ring and the second she gave him her necklace.
When the third night came she had nothing else to give him so the little man wanted her first born child. She had to agree because she did not want to be killed.
She became the King's wife and when they had their first born the little man gave her 3 days and 3 tries to figure out and guess his name. If she got it right they could keep their child.
She sent spies to spy on him a figure out his name, they found out it was Rumpelstiltskin. When the three days were up she guessed his name right and they got to keep their child.