Aladdin tricks Jafar into using his third wish to become an all-powerful genie. However, Jafar didn't count on having to be confined inside of his own lamp, and gets himself sucked into it, dragging Iago with him. The palace and everyone inside goes back to normal, and Genie sends Jafar's lamp to the Cave of Wonders. Aladdin then uses his third wish to free Genie, and the sultan changes the law so that the princess may marry whomever she deems worthy. Jasmine immediately chooses Aladdin, and the Genie departs to go see the world.