The Backlander teleports the D-Team back aboard, but the Space Pirates have already left Ancient Japan. However, Dr. Z won't let the ship leave until the Alpha Trio returns. They almost sneak away from the sleeping bears until Ursula sneezes, getting chased out of the cave and beamed up. The bears wave as the Backlander enters the time vortex.
Reese contacts the ship again, seeing the Pterosaur guide it towards the next time period, Jonathan sending her data they've collected before her transmission cuts off again. They arrive over the desert of Ancient Persia in 757 AD, the era of both traders and thieves. On its way through the desert, the caravan of Princess Zahrah, daughter of the Sultan, is ambushed by Zayid and the Gang of 39 Thieves (usually 40, but Fez was sick), and she is captured.
Getting a (rather rough) back massage by the Alpha Trio to improve blood flow to the brain, Dr. Z concludes that the Cosmos Stones are connected to dinosaurs and he wants them for himself. Meanwhile, Gabbro searches the desert for a secret door, finding a stone door in a mountain; he summons Afrovenator to bash it open with its head to no effect. The D-Team respond, watching as Gabbro leaves but the dinosaur signal remains. Max guesses the secret password as the famous phrase, "Open sesame!" It works, to everyone's shock. Inside, they find a cave full of golden treasure, a giant Isisaurus walking up, but with no Space Pirate emblem, and Zahrah standing beside it. Rex tries pulling her to safety, but she explains she summoned the harmless "Genie" from a lamp; Rex gets lovestruck upon seeing her. She'd been locked in here by the 39 Thieves, not seeing the water drop triggering the Isisaurus card in the lamp, or the Red Cosmos Stone in the cave's pond he swallowed. She was following his lead to the entrance, but decides to help the D-Team look for their Cosmos Stone. The Alpha Gang also arrives, Dr. Z joining them, looking for the dinosaur but finding the treasure. Outside, Gabbro brings in a Chinese monk to chant the door open like before, seeing it apparently worked really fast and letting the monk find his own way back to China as he heads in.
While searching, Max finds Genie's Card Capsule, but not the Cosmos Stone. Gabbro finds the Alpha Gang searching, Afrovenator easily defeating Spiny before heading farther in as the cave starts shaking. Confronting the D-Team, Afrovenator is defeated by Ace as Genie knocks away Gabbro, who thought the Cosmos Stone was in Zahrah's lamp. They race to avoid the cave-in.
The Alpha Gang is carting out bags of gold as the D-Team runs by with Genie. Zahrah trips, but Ace carries her out as the cave collapses behind them. She gives Rex a kiss on the cheek for saving her, shocking the others and freezing Rex. They hide as the 39 Thieves return, Max seeing Ursula's hand reaching out and saying, "It's the old lady", Ursula's rage throwing aside the rubble to get the Alpha Gang caught red-handed stealing the Thieves treasure and captured. As they leave, Zahrah overhears Zayid naming Rasheed, the Sultan's prime minister, and they head back to her city. Back inside, Gabbro survived the cave-in by having a dense head.
Riding Genie, the group trudges through a sandstorm, still a day away from the palace. Then a huge sand cyclone approaches them…
Ursula/Spiny vs. Gabbro/Afrovenator
Gabbro summons Afrovenator, but an angered Ursula summons Spiny, who knocks Afrovenator into the wall. They upgrade into Spectral Armor Afrovenator and DinoTector Spiny, headbutting. Afrovenator uses Tornado Toss, sending Spiny crashing into the ceiling and then to the ground, defeating him. It then rams through the Alpha Gang.
Rex/Ace vs. Gabbro/Afrovenator
Gabbro finds the D-Team, Spectral Armor Afrovenator roaring at Max. Zahrah calls for Genie to help, but Rex summons Ace instead to kick it aside, giving him his DinoTector form. Ace jumps over a charge and tail swing, kicking Afrovenator away from behind.
Gabbro blocks them, reaching for Zahrah's lamp, but Genie headbutts him into a stalagmite. Ace uses Hurricane Beat to defeat Afrovenator, destroying its Spectral Armor. Rex reclaims the card.
- Afrovenator dinosaur card
- Isisaurus dinosaur card
- Spectral Armor Afrovenator dinosaur card
- Tornado Toss move card
(after finding the treasure)
-Zander: "I'm going to start my own country!"
-Ed: "I'm going to start my own chain of tasty taco stands!"
-Dr. Z: "I'm going to buy your country and your taco stands and put up a solid gold statue of me instead!"
- The Japanese title is a reference to the names of various film adaptations of Aladdin "and his Wonderful Lamp", while the English title is a reference to Ali Baba and the Forty Thieves, both stories added to the Arabian One Thousand and One Nights compilation in a French translation and both inspiring the majority of the Ancient Persia arc's story.
- This appears to be the first use of the name "Backland" instead of "Backlander" for the Zeta Point timeship.
- The Dino Bracer's map of the dinosaur signal places this story somewhere near modern day Baghdad, Iraq.
- Because of the Silk Road trading route shown by the Backlander, the unfortunate monk's trip back to China won't be as difficult as it might otherwise seem.
- This marks the second time one of the characters says a dinosaur family order.
- It was never revealed where Genie's card came from, but given that it was contained in a Card Capsule, it would have to be one of the original dinosaur cards from Dr. Ancient's expedition. However, neither Dr. Z nor Dr. Ancient had previously noticed that the original collection was missing an Isisaurus card, but though this was likely due to the fact that the plot for this episode did not exist at the time of the season 1 finale, the plot hole was never addressed in or after this arc.
- It is also unknown how Genie's Capsule got into the past, but was likely a consequence of the accident in the time vortex scattering cards across all of history (such as Therizinosaurus' card ending up embedded in limestone, and Utahraptor and Fukuisaurus' Capsules coming out of prehistoric rocks), most merely only activating in the present day for story convenience. Without the events of season 2, Genie's card would probably have been lost forever.
- When Genie's card was activated, a yellow glow like a Lightning Dinosaur's comes from the lamp, even though Genie's actual card had a slight blue aura in the same shot, and he was glowing blue when he appeared in front of Zarah. It likely came from either the golden lamp the Capsule was in, or the Capsule itself, whose bulb ends have on occasion glowed when its card was activated, though in those cases it glowed in kind with the dinosaur's Element.
- When Genie ate the Red Cosmos Stone, he did not go out of control, as was the case later with Terry and Paris. The most likely explanation for this is that Genie's Water Attribute beats the Stone's Fire, so he avoided this negative effect. Had Genie eaten the Yellow Cosmos Stone, he would probably have been greatly weakened.
- This is the first episode of season 2 in which one of the six main dinosaurs was defeated in its DinoTector form, in this case Spiny.
- Unless he was recalled early instead of defeated, Spiny's card should've fallen to the ground instead of zipping back into Ursula's hand.
- Getting called an old lady again gives Ursula the superhuman strength to free the Alpha Gang from a pile of boulders in a cave.