The film is a very loose parody of the tale of Ali Baba and the Forty Thieves.
In the middle of the Arabian Desert, a rich Sultan has stored all his treasure in a cave, the door of which he closes with the command "Close, Sesame". He leaves a burly guard named Hassan to watch the cave, ordering him to let nobody enter, or else he will be punished. As the Sultan leaves on his tiny camel, the trail of a burrowing rabbit crosses the desert towards the cave. Hassan spots the burrow tunneling under the entrance of the cave and attempts to chase out the intruders, but finds he cannot remember the command to open the door again, trying "Open, sarsaparilla", "Open, Saskatchewan", "Open, septuagenarian", "Open, saddle soap" and so on. Hassan noticeably loses his fierceness and appears dumbfounded when he struggles to remember the proper command, until he correctly guesses it, to which he immediately regains his toughness and bellows out his usual favorite saying; "Hassan chop!"
Inside the cave, Bugs Bunny and his traveling companion Daffy Duck emerge from the burrow, believing they have arrived at Pismo Beach "and all the clams we can eat" (having once again missed that important left turn at "Alba-koi-kee"). Daffy's complaints about having to travel underground ("What a way for a duck to travel; underground!") and about seeing that they're not at the right place ("Hey, wait a minute! Since when is Pismo Beach inside a cave?") are soon silenced when he spots the mound of treasure. Determined to keep it all for himself he stomps repeatedly on Bugs to force him back into the burrow ("It's mine, you understand?! Mine! All mine! Get back in there! Down, down, down! Go, go, go! Mine, mine, mine! Mwahahahahahaha!") and dives into the treasure pile with whoops of delight to the tune of the song We're in the Money ("I'm rich! I'm wealthy! Yahoo! I'm comfortably well off.").
Outside the cave, Hassan eventually says the correct command to open the door and storms in to deal with the intruders. He is met by Daffy, who is wheeling a trolley full of loot. Daffy, believing him to be a Redcap, addresses him as "Boy" and asks him to call a cab. In response, Hassan brings his sword down on Daffy's head, splitting in half both the diamond-adorned hat he is wearing and a single upstanding hair underneath. Daffy, clearly amazed that he has not been cut in half himself, flees in terror and uses a large gem to try bribing Bugs into saving him, but Bugs, although himself susceptible to money-hunger in such cartoons as Baby Buggy Bunny and Barbary Coast Bunny, simply tosses Daffy's gem aside, only concerned with dusting himself off from the earlier abuse from Daffy.
Hassan rushes towards them both, sword raised, with the cry of "Hassan chop!" Daffy tells Hassan to chop the rabbit instead, but Bugs has already concocted a plan. He has squeezed into a tiny glass bottle, proclaiming himself to be a genie and offering Hassan a rich reward for releasing him. Hassan is fooled (though Daffy isn't, saying "He's lying! Chop him, chop him!") and shakes Bugs out of the bottle. In return, Bugs rewards Hassan by proclaiming him the new owner of the treasure (performing his "magic" to do so with a bizarre "iggity-aggity-oop" dance and chant). Daffy sardonically mocks Bugs for allowing Hassan access to the treasure he wanted for himself.
Later, outside the cave, Bugs surveys the desert and concludes that he has indeed come to the wrong place. A scream comes from the cave as Daffy runs out carrying an enormous diamond, with the enraged Hassan in hot pursuit shrieking "Hassan chop!". Daffy begs Bugs to save him, and this time Bugs reluctantly complies while berating Daffy for his greed. He sets up an Indian rope trick behind a rock, and when Hassan finds him, tells him that Daffy climbed up the rope. As Hassan disappears into the clouds, Bugs pulls the rope down, and, as with some variants of the fabled trick, Hassan has disappeared completely. With the coast clear, Daffy runs back to the cave to claim the treasure ("I'm rich! I'm wealthy! I'm independent! I'm socially secure!").
Some time later, Daffy has emptied the cave of treasure and is taking one last look around for any missed trinkets. He spots an old oil lamp and rubs the dust off it. A genie emerges from the lamp, but Daffy thinks the genie is after the treasure and proceeds to stomp him back into the lamp like he did with Bugs earlier ("Oh, no you don't! You want my treasure! Well, it's mine, understand?! All mine! Down! Down! Go! Go! Mine!"). The furious genie erupts from the lamp, declaring Daffy will suffer the consequences for "desecrating the Spirit of the Lamp," (Genie: Duck, you have desecrated the spirit of the lamp! Prepare to take the consequences!) and Bugs, knowing that nothing can save Daffy now, is so terrified that he utters a frightened Yipe and hurriedly escapes via burrow. Daffy dismissively tells the genie, "Consequences, schmonsequences, as long as I'm rich!" but the genie zaps Daffy with magic bolts from his fingertips.
Much later, Bugs has finally made it to Pismo Beach and, while tucking into the area's famous clams, casually wonders how Daffy's encounter with the genie worked out. Opening one clam and discovering a pearl inside, he soon finds out; Daffy, shrunk to a few inches in height, emerges from Bugs' burrow trail in the sand and claims the pearl for his own ("It's mine, you understand? Mine! Mine! All mine! Go! Go! Go! Do you hear me? Out! Out Out! Mine! Mine! Mine! There's only enough for me!"). Bugs closes the clam on the greedy duck ("I'm rich..I'm a happy miser!") with the words "Close, sesame."