Rapunzel's story has striking similarities to the 10th-century Persian tale of Rudāba, included in the epic poem Shahnameh by Ferdowsi. Rudāba offers to let down her hair from her tower so that her lover Zāl can climb up to her. Some elements of the fairy tale might also have originally been based upon the tale of Saint Barbara, who was said to have been locked in a tower by her father.
A lonely couple, who want a child, live next to a walled garden belonging to an evil witch named Dame Gothel. The wife, experiencing the cravings associated with the arrival of her long-awaited pregnancy, notices a rapunzel plant (or, in most translated-to-English versions of the story, rampion), growing in the garden and longs for it, desperate to the point of death. One night, her husband breaks into the garden to get some for her. She makes a salad out of it and greedily eats it. It tastes so good that she longs for more. So her husband goes to get some for her a second time. As he scales the wall to return home, Dame Gothel catches him and accuses him of theft. He begs for mercy, and she agrees to be lenient, and allows him to take all he wants, on condition that the baby be given to her at birth. Desperate, he agrees. When the baby is born, Dame Gothel takes her to raise as her own and names her Rapunzel after the plant her mother craved. She grows up to be the most beautiful child in the world with long golden hair. When she reaches her twelfth year, Dame Gothel shuts her away in a tower in the middle of the woods, with neither stairs nor a door, and only one room and one window. When she visits her, she stands beneath the tower and calls out:
- Rapunzel, Rapunzel, let down your hair, so that I may climb the golden stair.
Upon hearing these words, Rapunzel would wrap her long, fair hair around a hook beside the window, dropping it down to Dame Gothel, who would then climb up it to Rapunzel's tower room.
One day, a handsome prince rides through the forest and hears Rapunzel singing from the tower. Entranced by her ethereal voice, he searches for her and discovers the tower, but is naturally unable to enter it. He returns often, listening to her beautiful singing, and one day sees Dame Gothel visit, and thus learns how to gain access to Rapunzel. When Dame Gothel leaves, he bids Rapunzel let her hair down. When she does so, he climbs up, makes her acquaintance, and eventually asks her to marry him. She agrees.
Together they plan a means of escape, wherein he will come each night (thus avoiding the Dame Gothel who visits her by day), and bring Rapunzel a piece of silk, which she will gradually weave into a ladder. Before the plan can come to fruition, however, she foolishly gives the prince away. In the first edition of Grimm's Fairy Tales, she innocently says that her dress is getting tight around her waist (indicating pregnancy); in the second edition, she asks Dame Gothel (in a moment of forgetfulness) why it is easier for her to draw up the prince than her. In anger, evil witch cuts off Rapunzel's hair and casts her out into the wilderness to fend for herself.
When the prince calls that night, Dame Gothel lets the severed hair down to haul him up. To his horror, he finds himself staring at her instead of Rapunzel, who is nowhere to be found. When she tells him in anger that he will never see Rapunzel again, he leaps from the tower in despair and is blinded by the thorns below. In another version, she pushes him and he falls on the thorns, thus becoming blind.
For months, he wanders through the wastelands of the country and eventually comes to the wilderness where Rapunzel now lives with the twins she has given birth to, a boy and a girl. One day, as she sings, he hears her voice again, and they are reunited. When they fall into each other's arms, her tears immediately restore his sight. He leads her and their children to his kingdom, where they live happily ever after.
In some versions of the story, Rapunzel's hair magically grows back after the prince touches it.
Another version of the story ends with the revelation that Dame Gothel had untied Rapunzel's hair after the prince leapt from the tower, and it slipped from her hands and landed far below, leaving her trapped forever in the tower to die.
The seemingly uneven bargain with which "Rapunzel" opens is a common trope in fairy tales which is replicated in "Jack and the Beanstalk", Jack trades a cow for beans, and in "Beauty and the Beast", Belle comes to the Beast in return for a rose. Folkloric beliefs often regarded it as quite dangerous to deny a pregnant woman any food she craved. Family members would often go to great lengths to secure such cravings. Such desires for lettuce and like vegetables may indicate a need on her part for vitamins. From a scientific interpretation the enchantress Dame Gothel is rather obviously a witch or medicine woman, who had mastered the use and production of a plant or drug capable of saving Rapunzel's mother from complications of pregnancy. Ergotics, opioids, or cannabis can be considered candidates in the original Persian or subsequent versions of the tale, by analogy to the problem of Delphos' Oracle.
An influence on Grimm's Rapunzel was Petrosinella or Parsley, written by Giambattista Basile in his collection of fairy tales in 1634, Lo cunto de li cunti (The Story of Stories), or Pentamerone. This tells a similar tale of a pregnant woman desiring some parsley from the garden of an ogress, getting caught, and having to promise the ogress her baby. The encounters between the prince and the maiden in the tower are described in quite bawdy language. A similar story was published in France by Mademoiselle de la Force, called "Persinette". As Rapunzel did in the first edition of the Brothers Grimm, Persinette becomes pregnant during the course of the prince's visits.