Riku is a close friend of both Sora and Kairi. At one point he's drawn into darkness and becomes an antagonist, leading Sora to fight him in Hollow Bastion.
By the end of the first game, after Sora defeats Ansem, Riku enters the Door to Darkness alongside Mickey. In the sequel, he returns bearing the image of Ansem, reverting to normal once Ansem destroys Kingdom Hearts with his machine.
Riku fights alongside Sora against the final bosses, including members of Organization XIII and Xemnas. In the end, he returns home to Destiny Islands with Sora, where Kairi, Donald, Goofy, and Mickey are waiting.