While Aladdin and his friends chase after Abis Mal to stop his next plan, they go back in time and find Hamed and his caravan walking in a desert before Agrabah existed. They tell Hamed he should settle in the desert but Hamed is unconvinced. At night, he gets tackled by Abis Mal and Abnor Mal and gets thrown in an hourglass-shaped portal. Aladdin and Genie follow and save Hamed who is stuck in a tar pit at a prehistoric era. After getting Hamed back in the present time, Aladdin takes Abis' magic hourglass but it breaks and a giant portal sucks everyone in, where a battle ensues. Hamed sees the future Agrabah and decides to follow Aladdin's suggestion. After getting back in the desert and Aladdin and his friends go back to their time and after banishing Abnor for his betrayal, Hamed and his group are going to find Agrabah.