Sora rescues Kairi at the Hollow Bastion keyhole, after defeating Riku for the last time.
The confrontation with Riku at Hollow Bastion is the emotional pivot of the game. Once that fight is over, the path to the keyhole opens and Kairi is freed — the moment the whole first game has been building toward.
Hollow Bastion is a difficulty spike, and the boss encounters there punish an under-levelled party. Stock up on healing items, make sure your keyblade and armour are current, and save before the sequence begins. There is no shame in grinding a level or two first.
After the rescue, the story moves into its final stretch.