The gang goes to the palace of Upanistan and see his body. They fight Caliph's body in order to get it back together with his head, but when that happens, they find out that it's the head that's evil. Caliph makes the guards of the palace of Upanistan give him a shackle so his body won't escape his head. Then, he separates Aladdin's head from his body, which makes his head become "brainy." Aladdin's head says that if his body fights Caliph, he will never walk again, so the others take his body and leave Caliph's throne room.
Everyone is now outside the palace of Upanistan, with Aladdin's head not getting along with his body. The gang come up with a plan to rejoin Aladdin's head and his body, so they all go back to the palace. When they get there, Aladdin's head is on Genie's body and Genie's head is on Aladdin's body.
They get to Caliph's throne room and see the wizard confronting a musician. Aladdin's body gets down and is about to fight Caliph, but the wizard blasts a chandelier, causing it to fall on the body. Everybody else goes down and fight Caliph. They get the key to open the shackle, but Kapok tosses it into the flames. The guards grab Jasmine and hold her in place. Just as Kapok is about to separate Jasmine's head from her body, Aladdin's body holds a mirror in front of the Caliph. The shackle comes undone, and Caliph's head leaves his body and Aladdin's head gets back together with his body.
Caliph's body thanks the gang and Caliph's head is now in a cage. The gang then leaves Upanistan.