Ali Baba (
Aziz Sattar) is a poor man who cannot succeed in life. He constantly sends his wife to his brother Kassim Baba's house to borrow flour so they can eat, but the stingy Kassim Baba (
S. Shamsuddin) is frustrated at his brother and constantly reminds his wife, Norsiah, of Ali Baba's uselessness. When Norsiah comes to ask for flour for the umpteenth time, Kassim Baba loses his temper and lashes out at her sending her home in tears. She blames Ali Baba for putting her in the situation and blames him for not making an effort to seek a job. Ali Baba finally relents and goes out into the woods to gather firewood where he chances upon a group of 40 thieves marching through the woods carrying loot and treasures. He hides in a tree and watches their leader (
P. Ramlee) stand in front of a cave and sings a verse of seemingly nonsensical words (
niat ingsun matek aji semar ngising, actually a
Javanese language poem) which causes an entrance to the cave to open. Ali Baba waits until the thieves have all left the cave before coming out of the tree and using the magic words to open the cave. Inside, he discovers a variety of riches and wealth, but only takes a box of gold coins. With the gold coins, Ali Baba is able to pay Kassim back everything he owes and live in better comfort. Kassim Baba is overcome with curiosity and pesters Ali Baba to tell him how he suddenly came into wealth. Ali Baba eventually relents and tells Kassim about the cave and the magical verse to open it, but before he can tell him the verse to close the cave, or about the thieves who use it, Kassim Baba rushes off to find the cave. Kassim, in his greed, tries to steal everything in the cave. The thieves return, find the cave door open and quickly close it. Kassim, who has forgotten the chant to reopen the door, is trapped and caught. Kassim tries to stall, but the thieves eventually kill him. When Kassim does not return home, Ali Baba sneaks out to the cave, where he finds his brothers' remains. He collects Kassim and has him sewn together by bribing the town cobbler, Apek, to do it. The thieves eventually hear of Apek's strange "job", and identify Kassim Baba as the man they'd killed. The thieves plan to rob his house, which is now under the protection of Ali Baba. This attempt fails twice thanks to the interference of Marjina, Ali Baba's newest servant. The leader of the thieves, enraged by his men's incompetence, decides to look for the house himself. Once he has found it, he poses as an oil merchant visiting Ali Baba's house, while his thieves hide in oil jars that are kept in the courtyard. Marjina discover the hidden thieves and, with the help of Ali Baba's wife and widowed sister-in-law, pour boiling oil into all the individual jars. After all the thieves are defeated, Marjina attacks and kills the leader himself. Ali Baba, grateful for her loyalty, sets her free. ==Anachronisms==