Kingdom Hearts III begins in the Mysterious Tower, where the inevitable rebirth of Master Xehanort has forced Master Yen Sid to summon Riku and Sora to him and take their Mark of Mastery Exams to become true Keyblade Masters. The two friends take the Exam together, but only Riku is able to pass due to his original position as the Keyblade's chosen one and stronger heart. He is then given the task of bringing an end to Master Xehanort if the elderly Keyblade Master does indeed come back to life. Sora is ordered to return home to the Destiny Islands so that he may protect Kairi upon his failure, but he disobeys Yen Sid and follows after Riku with Donald and Goofy only to be surrounded by a swarm of bizarre creatures known as Forsaken. A mysterious hooded figure appears after Sora and his friends manage to vanquish the monsters, and it challenges the hero to battle in a test of strength. The Keyblade wielder is defeated, after which the Mysterious Figure reveals that it will ensure he is strong enough to partake in the "revival" and will destroy anyone who gets in its way. The Mysterious Figure vanishes in a corridor of darkness as Sora gives chase, the boy fearful for Riku's safety. Determined to help his friend, Sora leaves the Mysterious Tower with Donald and Goofy to begin his own journey. The Mysterious Figure later reappears before Kairi at the Destiny Islands, where it warns the young woman that her two childhood friends are now in serious danger because of it. Wielding a newly spawned Keyblade, Kairi obtains help from King Mickey and leaves for other worlds in hopes of bringing Sora and Riku back home safely.

Upon arriving in other worlds, Sora, Riku, and Kairi encounter various Disney characters, old and new, fighting off hordes of Forsaken along the way. Riku ends up attracting the attention of several Disney villains, who take advantage of the growing darkness in his heart and trick him into helping them accomplish their own dark agendas while convincing the young Keyblade Master that the truly sinister actions he is carrying out are actually helping to maintain peace. Meanwhile, Sora continues on his own quest to reunite with Riku and defeat the Mysterious Figure. He remains completely unaware that the chaos from which he saves the worlds is truly a result of Riku's actions until the two friends cross paths at the Radiant Garden and do battle, after which Riku states that he will do anything it takes to destroy Master Xehanort once and for all if it means protecting those he cares about, even if he must submit to the darkness once more. Riku vanishes, and Sora finds himself overwhelmed by pain as an intense light begins to shine from within the depths of his heart, after which Sora shouts out in a voice that is strangely familiar to him, yet not his own, the name "Terra." Kairi also gets more than she bargained for on her own visit to the Radiant Garden, where she finds a secret passageway within Ansem the Wise's laboratory that leads to the mysterious Chamber of Waking. The girl uses her Keyblade to enter the Chamber, where she encounters a suit of Keyblade Armor similar to her own. The armor comes to life and attacks her, Kairi feeling a strange familiar presence as she battles it with King Mickey. The armor opens a portal to the Realm of Darkness after its defeat, through which Kairi enters when she feels as if someone within is in need of her aid (the portal closes around her before Mickey has a chance to enter). Kairi comes to the Dark Margin and finds a hooded figure sitting on a large rock by the water there, believing it to be the Mysterious Figure and attacking it only to find her Keyblade locked with that of a young blue-haired woman. The mysterious Keyblade wielder conquers Kairi, and just as she prepares to finish her off, the hooded man rises and walks to her location. He reveals himself to be none other than Ansem the Wise, and when Kairi asks how he managed to survive the explosion of the Kingdom Hearts Encoder and why he had made no attempts to return to the outside world, Ansem changes the subject in shame and introduces the mysterious young woman beside him as Aqua. Kairi deduces that Aqua was the familiar presence she felt when she battled the animated Keyblade Armor in the Chamber of Repose, and that she was also the source of the mysterious feeling that someone within the portal the armor had opened was in need of assistance. Before the two Keyblade wielders can get better acquainted, however, a swarm of Forsaken surrounds them. Kairi and Aqua team up to battle the creatures and protect Ansem, but when dozens more begin to spawn, Ansem opens a corridor of darkness through which he states Aqua and Kairi can escape. He goes on to explain that he will not be accompanying them, as he had made too many mistakes in the outside world during his existence there (thus he felt he no longer belonged there) and holds the Forsaken off as Aqua steps into the corridor of darkness with Kairi. Kairi watches in terror as Ansem is struck down by the Forsaken just as the dark corridor closes, and Aqua holds her back when she makes a final desperate attempt to aid the elderly scholar.

Aqua finally free from the Realm of Darkness after twelve years, she reunites happily with King Mickey, who asks the young woman for help in the battle against Master Xehanort. Meanwhile, Sora finds himself drawn to the mysterious Castle Oblivion by the same light within his heart that had shined when he battled Riku. Using his Keyblade to unlock the sealed castle doors, Sora traverses the many Forsaken-infested levels of the castle with Donald and Goofy at his side. Unable to deny the feeling that he had been the castle before, Sora eventually comes to an ornately decorated white door in a secret basement of the castle. He again uses his Keyblade to open the doors, and he steps inside to find himself in the Chamber of Waking, the resting place of Ventus, whom Sora discovers unconscious sitting in a tall throne in the middle of the white room. An intense light shines stronger than ever from within Sora, and he is amazed to see his own heart fly out from within his chest and split into two. While half returns back to his own body, the other merges with Ventus, who finally awakens from his slumber. Sora feels as if he has known the boy for years and sees a lot of himself in him, after which Ventus goes on to explain that when Sora was young, his heart had merged with him after the climatic battle with his dark half, Vanitas. Ventus agrees to aid Sora in the second battle against Master Xehanort, and as the two prepare to exit Castle Oblivion with Donald and Goofy, the heroes find themselves trapped by chains of light forged by a mysterious animated suit of Keyblade Armor. It savagely attacks Sora and his friends, but when Ventus recognizes it as that of his deceased Master Eraqus, he identifies himself and the armor releases Sora, Donald, and Goofy. Sora hears the voice of Eraqus speaking from within him, begging him to bring balance back to the light and darkness and succeed where he had failed by putting an end to Master Xehanort once and for all. The armor vanishes, Sora, Ventus, Donald, and Goofy leaving Castle Oblivion behind and traversing to their next destination.

Travelling in-between worlds and desperate to find Master Xehanort, Riku is consumed by a bright light and finds himself in a mysterious desert world surrounded filled with thousands of rust-eaten Keyblades when he awakens. Kneeling before him is a suit of Keyblade Armor; one Riku feels a familiar presence emanating from. He challenges the Keyblade-wielding armor to battle without hesitating, finding himself easily overpowered. Riku shoots the armor with a beam of light from the tip of his Keyblade in a last attempt to vanquish it when it approaches him with confusing words and accusations, the armor collapsing to reveal a tall young man with brown hair whom Riku recognizes from his youth in the aftermath. The man introduces himself as Terra just in time for the Mysterious Figure to appear behind them with an army of Forsaken. The hooded enigma states that at last the time of revival has come. It defeats Riku and Terra and begins to shine with an intense dark aura, a ghostly image of Xemnas and Xehanort's Heartless appearing on either side of it. Too weak to stand, Terra and Riku can only watch as the two previously defeated antagonists merge with the Mysterious Figure to recreate Master Xehanort, the Mysterious Figure fading out of existence after the completion of its mission. Meanwhile Aqua, Kairi, and King Mickey arrive in the Keyblade Graveyard and reunite with Sora, Ventus, Donald, and Goofy, the heroes rushing to Riku and Terra's aid to begin the climatic final battle with Master Xehanort, the heroes all separated from one-another in the process as Kingdom Hearts appears in the sky above them. Terra and Riku manage to defeat Xehanort, who once again unlocks his heart and possesses Riku, hoping to use the darkness reborn in the young Keyblade Master's own heart as his new vessel. After Terra defeats the possessed Riku, however, he unlocks his heart as well and offers it to Riku in order to flush out Xehanort instead of heeding Riku's order to destroy him. Seeking vengeance for what Xehanort had caused him to do to Terra, Riku faces the physical Xehanort once again and defeats him once and for all. His final challenge is Xehanort's animated Keyblade Armor, which Riku defeats after it makes a desperate attempt to eliminate him now that it sees Riku's heart would never submit to it. Terra is revived in the aftermath of this battle. Meanwhile, the negativity surrounding Sora and Ventus during their struggle revives the once destroyed Vanitas. He, Sora, and Ventus are transported to the Awakening, where they begin a climatic war to prevent the X-blade from being forged as it had been twelve years ago. While this battle seems never-ending, Sora gains control of the X-blade after Ventus voluntarily fuses with Vanitas to create it when victory seems impossible otherwise. Sora empowered by Ventus, he faces Vanitas a final time, both Keyblade wielders utilizing the X-blade. Aqua and Kairi battle the Vanitas-possessed Sora, who is finally defeated through Sora's fighting to maintain control of his mind, body, and heart in combination with the actual Vanitas's defeat at the hands of the spiritual Sora from within the Awakening, which is truly the combined hearts of light belonging to Ventus and Sora himself. Sora's heart is destroyed along with the X-blade he managed to forge, however, and he only is able to awaken once Kairi confirms her feelings for him by shedding tears of remorse. Sora is revived just in time, as Kingdom Hearts begins to emit a strange glow. In a flash of light, Sora, Aqua, and Kairi are teleported within the heart of all worlds, where they are reunited with a reborn Ventus and Terra. The Mysterious Figure appears before them, revealing itself to be the source of the Forsaken and a fragment of Kingdom Hearts' power born during the legendary Keyblade War as a last resort method of protection against those that sought its power with the ability to destroy all worlds. The Mysterious Figure explains that it needed a Keyblade of Darkness (Xehanort) and one of Light (Sora) to clash before it could at last fuse with Kingdom Hearts and become whole again, the heroes hearing enough of its nonsense and battling it. The Mysterious Figure's hood is knocked off when it at last is defeated, and Sora is shocked to see his own face staring back at him, which eventually morphs into that of Riku, Kairi, Ventus, Aqua, and Terra. Sora deals the final blow the Mysterious Figure, and the heroes are transported from the Awakening back to the Keyblade Graveyard, where they are faced with the Mysterious Figure-possessed Kingdom Hearts. Upon the destruction of the heart of all worlds, peace is at last returned for good to the worlds, all those connected to Sora who were hurting freed from their torment.