In a desert, a large mechanical centipede comes over a sand dune and shoots fire at two nomads, who run away. The next day, at the palace dining room, Aladdin and the others have guests. One of the guests named Daru Tavelevil, who is a merchant, talks about art, impressing Jasmine with how cultured he is. Aladdin tells everyone that he's an adventurer, saying that he fought a giant dancing rhino. While he and Abu pretend to fight, Aladdin accidentally causes some chaos in front of everybody, which leaves him embarrassed.
At Aladdin's hovel, the street rat is still moping. Genie comes out and sees Aladdin depressed and Abu tells him that he embarrassed himself in front of the Sultan and the guests. Aladdin thinks that Jasmine thinks he's an oaf and wants to be cultured. Iago tells him not to mess up his hair and he gives him the Scroll of Witty Quotations which has all the "culture" talk.
The next day, the palace guards are walking in the desert where the nomads were two nights ago. They see the centipede shooting fire and they run off. Meanwhile at the palace garden, Aladdin is in his "Prince Ali" outfit and his hair is slicked back exactly like Daru's. When Jasmine shows up, Aladdin reads the scroll and does the "culture" talk, but Jasmine is not impressed, mostly because she doesn't know what he's talking about as his quotes make no sense. Instead she thinks he's acting strange. When the princess leaves, the guards show up and let Aladdin know about the centipede. Aladdin is about to check it out, but Iago tells him that trying to impress Jasmine is a better thing to do. So, he makes Genie check the centipede out instead.
When Genie goes to the desert, the centipede walks over to him and reveals that Mechanicles is actually controlling it. When Genie tries to fight him, the inventor tricks Genie into thinking that he needs his help getting a ship out of a bottle. When Genie gets inside, Mechanicles traps him in.
At night, at the palace dining room, Aladdin and the others are eating with the same guests from before. Jasmine is still annoyed with Aladdin's cultural behavior but Daru and the other guests are now impressed with the street rat. Jasmine takes Aladdin outside and wants to know if he's worried about Genie since he has been gone too long. Aladdin is worried and decides to send Carpet to look for Genie, but Jasmine wants all of them to go. While the group is at the canyon in the desert, they see the ground flat and shiny.
The centipede comes to them, traps them in a net, and brings them inside. The group finds Mechanicles controlling the centipede and Genie trapped inside the ship in the bottle. Mechanicles tells everyone that his plan is to iron the desert by turning the sand dunes into glass because he hates how it has wrinkles and bumps. Sfter noticing Aladdin's new hair do, Mechanicles then mentions Daru willing selling him the iron to attack Agrabah, making the group angry that the merchant has sold them out to get rich. Aladdin then tricks Mechanicles by being curious in knowing how he got the ship in the bottle. When the inventor opens the cover, Genie gets out and frees the others.
Everyone is now about to fight Mechanicles, but he pulls a lever that gets them out of the centipede. The group flies away on Carpet and sees the centipede heading for Agrabah. When they get on a rock outcrop, Jasmine angrily swears she's going to make Daru pay for his treason and Aladdin beats himself up for looking up to a traitor. Jasmine comforts Aladdin stating that they were all taken in with Iago adding how it amazes him how people fall for Daru stating "He had even less charm than Aladdin till I lent him the scroll and taught him the hair thing" which earns him angry looks from the others. Jasmine suggests that Aladdin warn Agrabah, but he says that he doesn't have time and they have to handle it themselves. He has a plan to trap the centipede into the canyon.
The group pushes two boulders, which land on the centipede. When they get down, they assume they defeated Mechanicles' invention, but the centipede segments stand up and start moving, independent of each other. Genie gets stuck in a hole on one of the segments, causing it too explode. Aladdin sees this happening and gets an idea. Everybody puts rocks on the holes of the centipede segments and they all explode. After all the segments explode, Mechanicles flies in the centipede's head with flapping metal wings. The inventor pushes a lever that makes a cannon emerge from the machine. Iago drops rock on the cannon and the machine drops to the ground just before it can attack the group. Mechanicles then accidentally pushes a lever that makes the machine shoot backwards over the horizon. He ends up in a frozen wasteland.
Later at the canyon, Razoul makes Daru put broken pieces of the centipede in a cart as punishment for his treason, while Aladdin, Jasmine, and Abu are watching. Meanwhile, Genie is reading the scroll that has everything Iago is saying, which annoys the parrot.