Kingdom Hearts
In Kingdom Hearts, Jafar kidnaps Jasmine because she is a Princess of Heart, and therefore needed to unlock the final keyhole. Sora, Donald, and Goofy meet Aladdin when they arrive at the entrance to the Cave of Wonders, where he joins the party as a temporary member. Jafar eventually steals Aladdin's magic lamp, which contains the Genie who grants the keeper of the lamp three wishes. He takes Jasmine to the Cave of Wonders. Jafar forces Genie to fight Sora, Donald, Goofy, and Aladdin, and then becomes a genie himself. However, the party defeats Jafar and seals him within his own magic lamp.
Afterwards, Sora locks the keyhole but is unable to save Jasmine. Though Aladdin is forbidden to leave his world in order to save her, Genie comes in the form of a Summon. Sora eventually rescues Jasmine, and she is returned to her home world to be with Aladdin.
 Kingdom Hearts: Chain of Memories
Agrabah appears in Castle Oblivion as one of Sora's memories. It follows essentially the same plot from Kingdom Hearts.
 Kingdom Hearts: 358/2 Days
 Kingdom Hearts II
When Sora and his friends return to Agrabah they discover Iago, Jafar's old pet bird. Iago claims he has changed his ways, and wants to be accepted by Aladdin and Jasmine. However, Pete soon arrives and wants Jafar's lamp. The old peddler of Agrabah has it and wants treasure "fit for a sultan" in return for it. Iago suggests that they go to the Cave of Wonders.
After going through the traps and Heartless there, Sora and the gang find a golden piece of treasure and return to Agrabah with it. Upon returning, they discover that Pete has robbed the peddler of his lamp. A battle ensues, and Sora fights two powerful Heartless (the Volcanic Lord and Blizzard Lord) for the lamp, defeating them. Agrabah is safe for now, but on the second trip, we find that the lamp has been stolen again, and Jafar is released. With the aid of the magic carpet, Sora fights Jafar and defeats him, thus securing the world.
Related ThreadsS.O.S from Agrabah - last post by @ Jun 25, 2010
Agrabah Help Please - last post by @ Jan 26, 2003
How do I activate new worlds after finishing Agrabah? - last post by @ Jan 18, 2003
Help in Agrabah - last post by @ Oct 2, 2009
agrabah...!!!! - last post by @ Jan 18, 2008