Context: One of the best-known tales in The Book of the Thousand Nights and One Night (also called The Arabian Nights' Entertainments) is "Ali Baba and the Forty Thieves." Hiding from a group of strange horsemen, Ali Baba hears their leader command a rock to open and then to shut after all the horsemen have entered a door in it. Following the later departure of the horsemen, Ali Baba uses the magic command; the rock opens, and he discovers a horde of stolen treasure, some of which he takes. The greed of Ali Baba's brother Kassim later leads to Kassim's murder in the cave and almost results in the killing also of Ali Baba. He is saved, however, by his servant Morgiana, whose ingenuity leads to the deaths of the thieves and the wealth of Ali Baba who prudently uses the fortune Allah has helped him to gain. "Open, Sesame!," one of the most famous magic commands in literature, first appears near the beginning of the tale:
The forty thieves carried their loads to the foot of a large rock which lay at the bottom of the little hill. Then they set down the bags, and the chief cried out in the direction of the rock: "Open, Sesame!" [in some translations, Simsim]. At once the surface of the rock gaped; the captain waited until his followers had passed with their burdens through the opening, and then carried his bag in after them. "Shut, Sesame!" he cried from within; and the face of the rock closed upon him. . . .