Ali Baba and the Forty Thieves

""Open sesame!""

"Ali Baba and the Forty Thieves" is a story from the Arabian Nights.

Ali Baba, a poor woodcutter, stumbles on the treasure cave of a band of robbers, which is magically sealed and must be opened by speaking the words "Open Sesame". He takes some of the treasure from the cave and becomes rich, but the robbers discover their loss and come in search of him. Their attempts to identify him and then to kill him are repeatedly foiled by the clever slave-girl Morgiana, and all the thieves wind up dead. Morgiana marries Ali Baba's son, and the family lives happily ever after.

Although the story is best-known as part of the Arabian Nights, and is one of the best-known stories from the Arabian Nights, it appears to be a late ring-in. The earliest existing written version is in the first European translation of the Arabian Nights, published in the 18th century by Antoine Galland, and it's thought that he included the tale from a separate source.

This story provides examples of:

 * Guile Hero: Morgiana.
 * Needle in A Stack of Needles: One of the thieves learns the location of Ali Baba's house, and puts a mark on his door. While he's away fetching the rest of the thieves, Morgiana puts the same mark on every other door in the street.
 * Open Sesame: Trope Namer
 * Sacred Hospitality: A dinner guest at Ali Baba's house says that he is unable to eat anything with salt in; his excuse is a dietary restriction, but actually he's the bandit chief, come in disguise to kill Ali Baba, and if he eats salt while he's a guest, he has "shared salt" with his host and is bound by the laws of hospitality.
 * Treasure Room: The thieves' cave.
 * Try Everything: Ali Baba's brother Kasim attempts his own raid on the thieves' cave, but forgets the password, attempting several different kinds of grain without recalling the right one. "Open Barley?"