The film's third act shifts from a romantic comedy to a high-stakes battle of wits. After Aladdin's facade as Prince Ali is exposed, Jafar manages to steal the magic lamp through his parrot, Iago. Jafar uses his first two wishes to become Sultan and the world's most powerful sorcerer, brutally subjugating Jasmine and her father, and banishing Aladdin to a frozen wasteland.
The climax reveals Aladdin's true growth. Realizing he cannot defeat Jafar using brute strength or magic, Aladdin relies on his street-smart cunning. He plays on Jafar's fatal flaw—his massive ego and insatiable greed—by pointing out that no matter how powerful Jafar is, the Genie will always be more powerful. Baited by this perceived slight, Jafar uses his final wish to become an all-powerful genie. This is the ultimate twist: in his lust for power, Jafar forgets the itty-bitty living space rule of genies. The moment his wish is granted, he is shackled in mystical cuffs and sucked into his own black lamp, taking Iago with him.
In the aftermath, Aladdin is left with one final wish. Instead of wishing to be a prince again to legally marry Jasmine, he honors his promise and uses his last wish to free the Genie. This act of ultimate selflessness moves the Sultan to abolish the archaic marriage law, allowing Jasmine to choose Aladdin. The ending subverts the typical fairy-tale resolution by prioritizing personal integrity over magical shortcuts.