This story has been used as a popular story pantomime plot such as in the pantomime/musical Chu Chin Chow (1916). Like many other folk tales frequently adapted for children, the original tale is darker and more violent than the more familiar bowdlerised versions. Popular perception of Ali Baba, and the way he is treated in popular media, sometimes implies that he was the leader of the "Forty Thieves": in the story he is actually an honest man whom fortune enables to take advantage of the thieves' robberies.
Some critics believe that this story was added to One Thousand and One Nights by one of its European translators, Antoine Galland, an 18th-century French orientalist who may have heard it in oral form from a Middle Eastern story-teller from Aleppo, in modern day Syria. In any case, the first known text of the story is Galland's French version. Richard F. Burton included it in the supplemental volumes, rather than the main collection of stories, of his edition of the Thousand and One Nights, and seems to have thought it Greek Cypriot in origin.
Ali Baba and his elder brother Cassim are the sons of a merchant. After the death of their father, the greedy Cassim marries a wealthy woman and becomes well-to-do, building on their father's business—but Ali Baba marries a poor woman and settles into the trade of a woodcutter.
One day Ali Baba is at work collecting and cutting firewood in the forest, and he happens to overhear a group of forty thieves visiting their treasure store. The treasure is in a cave, the mouth of which is sealed by magic. It opens on the words "iftah ya simsim" (commonly written as "Open Sesame" in English), and seals itself on the words "Ikfil ya simsim" ("Close Sesame"). When the thieves are gone, Ali Baba enters the cave himself, and takes some of the treasure home.
Ali Baba and his wife borrow his sister-in-law's scales to weigh this new wealth of gold coins. Unbeknownst to them, she puts a blob of wax in the scales to find out what Ali Baba is using them for, as she is curious to know what kind of grain her impoverished brother-in-law needs to measure. To her shock, she finds a gold coin sticking to the scales and tells her husband, Ali Baba's rich and greedy brother, Cassim. Under pressure from his brother, Ali Baba is forced to reveal the secret of the cave. Cassim goes to the cave and enters with the magic words, but in his greed and excitement over the treasure, he forgets the magic words to get back out again. The Thieves find him there, and kill him. When his brother does not come back, Ali Baba goes to the cave to look for him, and finds the body, quartered and with each piece displayed just inside the entrance of the cave as a warning to anyone else who might try to enter.
Ali Baba brings the body home, where he entrusts Morgiana, a clever slave-girl in Cassim's household, with the task of making others believe that Cassim has died a natural death. First, Morgiana purchases medicines from an apothecary, telling him that Cassim is gravely ill. Then, she finds an old Tailor known as Baba Mustafa whom she pays, blindfolds, and leads to Cassim's house. There, overnight, the Tailor stitches the pieces of Cassim's body back together, so that no one will be suspicious. Ali Baba and his family are able to give Cassim a proper burial without anyone asking awkward questions.
The Thieves, finding the body gone, realize that yet another person must know their secret, and set out to track him down. One of the Thieves goes down to the town and comes across Baba Mustafa, who mentions that he has just sewn a dead man's body back together. Realizing that the dead man must have been the Thieves' victim, the Thief asks Baba Mustafa to lead the way to the house where the deed was performed. The Tailor is blindfolded again, and in this state he is able to retrace his steps and find the house. The Thief marks the door with a symbol. The plan is for the other thieves to come back that night and kill everyone in the house. However, the Thief has been seen by Morgiana and she, loyal to her master, foils his plan by marking all the houses in the neighborhood with a similar marking. When the forty Thieves return that night, they cannot identify the correct house and their leader, in a furious rage, kills the unsuccessful Thief. The next day, another Thief revisits Baba Mustafa and tries again, only this time, a chunk is chipped out of the stone step at Ali Baba's front door. Again Morgiana foils the plan by making similar chips in all the other doorsteps. The second Thief is killed for his failure as well. At last, the leader of the Thieves goes and looks for himself. This time, he memorizes every detail he can of the exterior of Ali Baba's house.
The Chief of the Thieves pretends to be an oil merchant in need of Ali Baba's hospitality, bringing with him mules loaded with thirty-eight oil jars, one filled with oil, the other thirty-seven hiding the other remaining thieves. Once Ali Baba is asleep, the Thieves plan to kill him. Again, Morgiana discovers and foils the plan, killing the thirty-seven Thieves in their oil jars by pouring boiling oil on them. When their leader comes to rouse his men, he discovers that they are all dead, and escapes. The next morning Morgiana tells Ali Baba about the thieves in the jars: they bury them and Ali Baba shows his gratitude by giving Morgiana her freedom.
To exact revenge, after some time the Chief of Thieves establishes himself as a merchant, befriends Ali Baba's son (who is now in charge of the late Cassim's business), and is invited to dinner at Ali Baba's house. However the Thief is recognized by Morgiana, who performs a dance with a dagger for the diners and plunges it into his heart when he is off his guard. Ali Baba is at first angry with Morgiana, but when he finds out the Thief tried to kill him, he is extremely grateful and rewards Morgiana by marrying her to his son. Ali Baba is then left as the only one knowing the secret of the treasure in the cave and how to access it.
- The story was made into an Egyptian movie in 1942 as Ali Baba We El Arbeen Haramy (Ali Baba and the Forty Thieves), with Ali AlKassar playing the lead as Ali Baba, and the comedian actor Ismail Yasin as his assistant.
- A French film Ali Baba et les quarante voleurs starring Fernandel and Samia Gamal (1954).
- A French telefilm starring Gérard Jugnot and Catherine Zeta-Jones (2007).
- In the 1970s, the Ali Baba story was adapted in a Bengali film called Morgiana Abdulla.
- A Soviet-Indian joint film of 1979 Ali Baba aur 40 Chor, starring Dharmendra, Hema Malini, Rolan Bykov and Zeenat Aman, was largely based on this adventure tale.
- A Malaysian comedy film, Ali Baba Bujang Lapok (1960) which quite faithfully adhered to the tale's plot details, but introduced a number of anachronisms for humour, for example the usage of a truck by Kassim Baba to steal the robbers' loot.
- There are two Tamil films under the title Alibabavum 40 Thirudargalum ("Alibaba and Forty Thieves"). The first film starring N. S. Krishnan as Ali Baba released in 1941, the second film starring M. G. Ramachandran, released in 1956.
- The story was adapted in the 1971 anime Ali Baba and the Forty Thieves (アリババと４０匹の盗賊 Aribaba to Yonjuppiki no Tozoku ), storyboarded by Hayao Miyazaki.
- The concept of Ali Baba and the Forty Thieves was used for the last installment of Disney's Aladdin series, Aladdin and the King of Thieves, released in 1996, introducing Cassim the King of Thieves as Aladdin's father.
- In the television mini-series Arabian Nights, the story is told faithfully with two major changes. The first is that when Morgiana discovers the thieves in the oil jars, she alerts Ali Baba and together with a friend, they release the jars on a street with a steep incline and allow them roll down to break open. Furthermore, the city guard is alerted and arrest the disoriented thieves as they emerge from their containers. Later when Morgiana defeats the thief leader, Ali Baba, who is young and has no children, marries the heroine himself.
- A film adaption Ali Baba and the Forty Thieves was made in 1944. The film was remade in 1965 as The Sword of Ali Baba. Frank Puglia portrayed the character named Kassim in both versions.
- At the United States Air Force Academy, Cadet Squadron 40 was originally nicknamed "Ali Baba and the Forty Thieves" before eventually changing its name to the "P-40 Warhawks".
- A mythopoeic novel by Tom Holt, Open Sesame, is based on characters from the story of Ali Baba and the Forty Thieves.
- Although not a direct adaptation, the characters of Ali Baba, Cassim, and Morgiana as well as part of the concept of the Forty Thieves are featured in the ongoing Japanese comic series called Magi. An adaptation of this manga to anime was made in 2012.
In other media
- A Merrie Melodies Bugs Bunny/Daffy Duck cartoon, Ali Baba Bunny, has a similar premise to the concept of the treasure-filled magical cave.
- A Popeye cartoon, Popeye the Sailor Meets Ali Baba's Forty Thieves, features Popeye meeting and defeating the titular group.
- In the Disney film Aladdin there are several references to the story. Also, in Aladdin and the King of Thieves the forty thieves play an integral part in the story. However the story is very different than the original Ali Baba story, particularly Cassim's new role as the King of Thieves.
- In the Simpsons episode "Moe Goes from Rags to Riches", Lisa is Scheherazade and Nelson Muntz is King Shahryar, and Lisa tells him the story.
- A 1981 computer video game by Quality Software
- A version of Ali Baba appears in Sonic and the Secret Rings, where he is portrayed by the character Tails.
- The Beastie Boys reference Ali Baba in their 1986 song "Rhymin' and Stealin'".
The name "Ali Baba" was often used as derogatory slang by American and Iraqi soldiers and their allies in the War in Iraq to describe individuals suspected of a variety of offenses related to theft and looting. British soldiers routinely used the term to refer to Iraqi civilians. In the subsequent occupation it is used as a general term for the insurgents, similar to Charlie for the Viet Cong in the Vietnam War. Due to interaction of the two peoples, the term "Ali Baba" was adopted by the Iraqis to describe foreign troops suspected of looting, and the English-speaking mainstream press mistakenly reported the slang to be native to the locals.
A depiction of the Forty Thieves.
The Forty Thieves attack Cassim.
A member of the Forty Thieves tries to discover the location of the house of Ali Baba.
A member of the Forty Thieves marks the door of Ali Baba
Morgiana pays Baba Mustafa the Cobbler.
Morgiana pours boiling hot oil into the sacks containing the infamous Forty Thieves.
Ali Baba presents treasures from the magical cave of Sesame to Morgiana.
- Burton, R. F. Supplemental Nights to the Book of the Thousand Nights and a Night with Notes Anthropological and Explanatory, Vol. III, fasc. 2, p. 369(n.) PDF.
- Duncan Black MacDonald, ‘“Ali Baba and the forty thieves” in Arabic from a Bodleian MS’, Journal of the Royal Asiatic Society (April 1910): 327-386.
- Ali Baba or the 40 Thieves http://www.tapestrykinetics.com/ali_baba.html
- Barton, Matt (2007-02-23). "Part 2: The Golden Age (1985-1993)". The History of Computer Role-Playing Games. Gamasutra. Archived from the original on 30 March 2009. Retrieved 2009-03-26.
- Vasagar, Jeevan. Court martial hears of drowned Iraqi's final moments. Retrieved on 2007-04-18.
- Richard Norton-Taylor Guardian 21 September 2009
- Fumento, Michael. Back to Falluja: The Iraqi Army versus the Keystone Kops insurgency. Retrieved on 2007-04-18.
- Levin, Jerry. Will The Real Ali Baba Please Stand Up Retrieved on 2007-04-18.
- Human Rights Watch. The Security situation immediately after the fall of Basra. Retrieved on 2007-04-18.