In Kingdom Hearts 3D: Dream Drop Distance, Yen Sid, a strong sorceror and ex- Keyblade Master, puts both Sora and Riku through a Mark of Mastery test so that they can become full-fledged Keyblade Masters and counter the soon-to-come return of Master Xehanort. As part of this trial, Sora and Riku get separated from each other and are sent to worlds priorly destroyed by the Heartless that have since been restored. However, the two are now in a state of “deep sleep” that disconnects them from the other worlds. These worlds are plagued by Dream Eaters, which are creatures born from darkness that seek out the sleeping worlds’ Keyholes. Before they become Keyblade Masters, Sora and Riku must reawaken the sleeping worlds by unlocking the seven Keyholes they find there. Then, they need to return to the realm of light, recruiting good “Spirit” Dream Eaters to help them on their journey and battle the evil “Nightmare” Dream Eaters.
Throughout the test, Sora and Riku have encounters with their old enemies, Xemnas and Ansem, as well as a younger incarnation of Xehanort who has traveled through time from a different past. As soon as all of the sleeping worlds are restored, Sora finds himself back in The World That Never Was instead of the Realm of Light, where he learns of Organization XIII’s real purpose: to serve as vessels for Master Xehanort to place pieces of his heart inside, allowing them to transform into clones of Xehanort. Sora is forced into a state of deep unconsciousness by the young Xehanort and his heart is swallowed by darkness. However, Sora’s heart is protected by Ventus’ suit of armor which resides within him. Riku tries to rescue Sora, but then he is confronted by the young Xehanort. Xehanort unveils a new Organization which is made up of the newly revived Master Xehanort and his twelve vessels, whom Xehanort plans to use against seven Keyblade wielders and recreate the χ-blade. Master Xehanort attempts to turn Sora into the remaining vessel he needs, but Sora is rescued by Riku, Mickey, Donald, Goofy, and Lea (the revived human form of the original Organization’s Axel). Afterwards, Xehanort and his other vessels go back to their own pasts.
Sora’s body is returned to Yen Sid’s tower, where Riku enters his body and releases Sora’s heart from Ventus’ armor, which is now possessed by a Nightmare. As soon as Sora reawakens, only Riku is declared a Keyblade Master by Yen Sid for getting Sora to wake up again. Undaunted by his failure, Sora congratulates Riku and sets out on a new journey by himself to train. The game’s secret ending shows Yen Sid planning to collect seven Keyblade wielders to combat the new Organization and stop Xehanort from causing another Keyblade War. To this end, Yen Sid has Riku bring his friend Kairi to him so that she can be trained with Lea to wield the Keyblade she used in Kingdom Hearts II and the Keyblade he developed with the ability to summon during the course of the game.