"Ali Baba and the Forty Thieves" is a story from the Arabian Nights originally written by Syrian Maronite writer Hanna Diyab.
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 his brother Kasim, a greedy merchant, discovers this new wealth and demands to know the secret of the cave. Unfortunately, once inside he forgets the magic password to open the door, and subsequently, he is discovered by the robbers and killed. They cut his body into quarters and hang it up at the entrance to the cave. Ali Baba finds his brother's body, and buries him, doing what he can to disguise the cause of death, but the robbers realize that someone else has discovered their hiding place. Their attempts to identify Ali Baba and kill him are repeatedly foiled by a clever slave-girl named Morgiana, and all the thieves wind up dead. Morgiana marries Kasim's son, Ali Baba makes Kasim's widow his second wife, 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 was originally written by Syrian Maronite writer Hanna Diyab in the early 18th century. Diyab had recounted the story to Antoine Galland, the French translator, at Galland's request and went on to include them in the Thousand and One Nights without crediting him. This theft was exposed when Diyab's autobiography was found in 1993 and greatly expanded our understanding of some of the most popular tales from the collection such as Aladdin (which Diyab is also the original author of).
This story provides examples of:
- Action Girl: Morgiana is a borderline case. She personally kills 38 of the 40 thieves, and her last kill is up close and personal, with a knife.
- Asshole Victim: In some versions, Kasim bullies or blackmails Ali Baba into revealing the secret of the cave. You don't feel too sorry for him when he meets his fate.
- Bad Boss: The leader of the thieves angrily kills two of the thieves after they leave a mark in some way to keep Ali Baba's house recognizable for them to return to kill Ali Baba, but Morgiana marks numerous houses in the same way to make the markers useless... in spite of how this clearly indicates their failures are due to someone else's intentional meddling rather any fault of their own.
- Big Bad: The chief bandit of the 40 Thieves.
- Blindfolded Trip: Morgiana does this with Baba Mustafa the tailor, leading him to Kasim's house so Mustafa can stitch Kasim's body back together. This precaution fails when the bandits arrive to seek Ali Baba — on three separate trips the blindfolded Mustafa successfully retraces his steps to lead the bandits to Kasim's house, where Ali Baba is now living.
- Canon Immigrant: As noted above, this tale was not included in any of the ancient manuscripts that make up the Arabian Nights and in fact, there is no source for it before Antoine Galland included it in his early 18th-century translation of the Arabian Nights into French.
- Character Name and the Noun Phrase
- Dead Guy on Display: Poor Kasim, chopped up in quarters and hung outside the door to the cave as a warning.
- Decoy Protagonist: Ali Baba is the protagonist at first, but he pretty much stops being such after he recovers Kasim's body; at that point, the story belongs to Morgiana, with Ali Baba now a supporting character.
- Desert Bandits: The 40 thieves rob caravans then place the bounty in their magic cave.
- Faking the Dead: An odd case where the victim truly is dead but the manner of death needs to be faked. Kasim's household spends two or three days building the ruse that their master is desperately ill, so when he is finally pronounced 'dead' it raises no suspicion.
- Family-Unfriendly Death: In order to infiltrate Ali-Baba's house the chief bandit poses as an oil merchant and hides his men in large oil jars. (One of the jars actually does contain oil, to keep up the ruse). When Morgiana discovers the hiding bandits, she dispatches them all by heating the oil to boiling and pouring it over them.
- Feminist Fantasy: Sure, Ali Baba's the one who finds the cave and retrieves Kasim's body, but everything else in the story, including killing the bandits, is performed by Morgiana the slave-girl.
- Greed: Kasim's Fatal Flaw. He apparently intends to loot the whole treasure cave in one take, lingers too long and forgets the password.
- Guile Hero: Morgiana.
- He Knows Too Much: At first, this is the reason why the Bandit Chief devotes so much time to finding and killing Ali Baba, to keep the location of his hoard a secret. (When all his men are dead, however, it becomes a matter of self-preservation.)
- 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 sees the mark, and thinking quickly she puts the same mark on every other door in the street. A second thief tries to mark the door more surreptitiously, but Morgana notices the mark anyway and does the same thing. The leader of the thieves is smarter, however, and chooses to study the house and area until he memorizes the location.
- No Good Deed Goes Unpunished: Refusing to leave his brother corpse's defiled and wanting to bury him properly is what puts the bandits on Ali Baba's trail.
- Open Sesame: The Trope Namer. It also requires a "Shut Sesame" upon leaving the cave.
- Plunder: The titular thieves got their treasure from raiding caravans, but Ali Baba and his family gets to be the ones to really enjoy it.
- Rags to Riches: Finding the bandits' hoard makes Ali Baba rich overnight, and he remains sensible enough (unlike his brother) to let the money last and keep his family and his son's family living in splendor for their entire lives. Morgiana also gets to go from a slave-girl to living as the daughter-in-law of a wealthy family (either in Ali Baba's or Kasim's widow's).
- Riddle for the Ages: Everything about the story is pretty much entirely mundane aside from the cave that opens and closes only to the words "Open/Shut Sesame". Just how the cave does this is never brought up.
- Sacred Hospitality: A dinner guest at Ali Baba's house says that he is unable to eat salt; 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. Clever Morgiana quickly figures out that this man is up to no good.
- Slave Liberation: Ali Baba frees Morgiana after she saves his life multiple times.
- Spanner in the Works: Ali Baba's cover is blown when Baba Mustafa, the tailor, brags to a stranger that he is so skilled he can sew a human body back together. Later, Kasim's son unwittingly brings the bandit chief into Ali Baba's home.
- Spell My Name with an "S": Depending on the version of the story, Ali Baba's brother is either spelled "Kasim", "Cassim", or "Kasym".
- Morgiana's name also appears as "Morgana" or "Mardschana" in various versions.
- Sibling Yin-Yang: Kasim is greedy and impetuous, quickly threatening Ali Baba to grant him where he's getting the treasure from and dies from attempting to grab it all at once (and forgetting the "Open Sesame!" password). Ali Baba is abundantly portrayed as a lot more prudent instead and almost generous by comparison - Ali Baba first only takes one bag of gold reasoning it won't be noticed missing; before Kasim demanded to know where the treasure came from specifically, Ali Baba offered to give him a share in spite of the fact Kasim's ignored him up until now; Ali Baba rewards Morgiana repeatedly for saving his life; he waits a whole year to return to the cave after the bandit leader's death and allows for the possibility of the two (unbeknownst to him, already killed) bandits unaccounted for absconding with the cave's treasure rather than risk trouble with them; and he makes the money in the cave last to keep his family and his sons' living richly for the rest of their lives (and thus in the version where he makes her his daughter-in-law, Morgiana will also become wealthy).
- Sisterhood Eliminates Creep: Ali Baba's wife Zainab and Qasim's widow Fatima become the ones to defeat the robber leader Hassan together. Zainab gets him drunk and Fatima kills him. Technically, there are thirty-eight more robbers, but they are such idiots that Fatima disposes of them within seconds, and only Hassan is really dangerous.
- Standard Hero Reward: Ali Baba marries either his son or his nephew to Morgiana as a reward for her heroism. Ali Baba doesn't exactly have a kingdom, but marrying his son would mean Morgiana gets to live as richly as Ali Baba's own family as well.
- Stupid Evil: The Forty Thieves are obsessed with finding Ali Baba to silence him, and just don't know when to quit. They spend a fortune to find the place (as the tailor gets smart and charges a larger fee each time) two of them are killed by the leader for messing up, and when they finally do find his house, all of them but the leader are killed in the attempt. But the leader still doesn't give up, and his final attempt gets him killed. Relocating and setting up shop elsewhere may have been the smart thing, but they clearly lacked smarts.
- Treasure Room: The thieves' cave. In the end, it's the sole property of Ali Baba and his children.
- 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?"
- Women Are Wiser: Kasim's wife discovers Ali Baba's new treasure; Morgiana foils all of the thieves' attempts to harm him. Meanwhile, Kasim forgets how to exit the cave, and Ali Baba never once realizes his life is in danger until Morgiana's already saved him.
- You Have Failed Me: The bandit leader kills two of his men who volunteer to find the house and mess up. (See Needle in a Stack of Needles, above.) Then he wises up and decides to do it himself.