Marluxia leads Sora to a place called Castle Oblivion. Sora & co. start going up the floors, one by one, looking for the King and Riku. They discover that each floor replicates each world from Sora's memories. Sora "remembers" a girl named Naminé, who replaces Kairi in his memories. He then finds Riku, who seems to have the same memories as Sora for some reason. Sora finally finds Naminé, only to find out that she is the one who has been messing with his memories. Turns out that Organization XIII (who Sora has been meeting throughout the castle) has traitors, and these traitors are trying to make Sora their slave using Naminé to rearrange his memories so she can make him do whatever she wants him to do. The Riku that was introduced in the castle was actually a replica of the real Riku, created by the Organization, and fake memories were given to him. Sora defeats all of the organization members he met in the castle (Vexen, Larxene, Marluxia) with the exception of Axel. Before disposing of Vexen, he took Sora to a place he said was a memory from the "other side of his heart". This world was Twilight Town. Sora finally got to Naminé, and she gave Sora a choice to either keep the memories of the castle, or regain his old memories and lose the ones from the castle. Sora chose the latter. The only way he could regain his memories is if he was put to sleep so Naminé could put his memories back together for a year. Sora does so, but not before making a note in Jiminy's journal to "Thank Naminé" for returning his memories back to him.
Meanwhile, Riku finds himself in the basement of Castle Oblivion, without the aid of the King. A mysterious explains to him the rules of Castle Oblivion, how each level is a world from his memories. However, since Riku pushed all of his friends out of his life for the power of darkness, he doesn't see anyone in the castle except for beings of darkness. Xehanort's heartless ("Ansem") appears to him, stating he was revived through Riku's darkness. Riku decided to destroy the darkness of his memories, and if he succeeds he will take out Ansem. Various times Ansem proved to be too powerful for him, and the King had to interfere, sending but a portion of his spirit to help Riku. Riku finally makes it to Ansem, and defeats him with the help of the King (the actual king, not a portion of his spirit). The King explains to Riku how he showed him that darkness isn't all bad. When Riku was asked which path he would take, the one to light or dark, by DiZ, he chose the inbetween path, the road to dawn.
I don't usually do this, but this took a lot of time, and I think I deserve some rep...=D