Kingdom Hearts Birth by Sleep
In order to replace his aged, dying body and survive the second Keyblade War, Master Xehanort leads Terra into being seduced by the darkness, eventually succeeding just as he is defeated by the youth at the Keyblade Graveyard. Turning his Keyblade on himself, he releases his heart and casts it into Terra's body, creating "Terra-Xehanort". However, Terra's anger animated his former armor as the Lingering Will, which attacks Terra-Xehanort and knocks him out. In the ravine below, Aqua and Ventus manage to defeat Vanitas and destroy the χ-blade, creating a lightstorm that sweeps Terra-Xehanort away to Radiant Garden.
After Aqua secures the stricken Ven within Castle Oblivion, Terra's heart calls out to her to put an end to his possessed body. She finds him, amnesiac, within Radiant Garden's Central Square, but he attacks her when Xehanort's heart stirs. She fights him off as Terra's heart struggles within, and the frustrated Terra-Xehanort turns his Keyblade on himself to rid himself of Terra's influence, inadvertently summoning a deluge of darkness that drags him into the Realm of Darkness. Aqua follows and sends him back to the Realm of Light using her Keyblade Armor and Keyblade, while she herself falls deeper into the darkness.
Terra-Xehanort is once more found comatose and amnesiac in Central Square, this time by his co-conspirator Braig, who leads Dilan and their master, Ansem the Wise, to the young man's location. Only able to recall the name "Xehanort", which he treats as his own, Terra-Xehanort is taken back to Ansem's castle, where he is nursed back to health and becomes one of the king's best apprentices, serving as a research assistant alongside his other apprentices, Braig, Dilan, Even, Aeleus, and Ienzo.
Some time later, within Xehanort's heart, Master Xehanort and Terra's hearts argue over Terra's fate, both certain that they alone will one day succeed, and the elderly Master realizes that Eraqus's heart has also taken root within their shared body. In the physical world, Braig attempts to discern whether "Xehanort" is truly amnesiac, or possibly actually Terra, but a confused Xehanort shrugs him off, convincing Braig to bide his time.
Between Kingdom Hearts Birth by Sleep and Kingdom Hearts
In order to protect the people of Radiant Garden, Ansem the Wise resolved to investigate how darkness originates and spreads within the heart. Chamber of Repose, beneath his castle, to further investigate the heart and the darkness that lies within it. Eventually, he abandoned the research, deeming it too dangerous to continue.Xehanort volunteered to be a test subject for a series of psychological tests, which Ansem and Even hoped would uncover Xehanort's repressed memories. At Ienzo's encouragement, Ansem constructed a massive laboratory, the
Without his knowledge, Xehanort and the other apprentices decided to experiment further than Ansem had ever intended, abducting large numbers of test subjects and actually cultivating greater darkness within hearts.  Xehanort also masqueraded himself as Ansem in order to subvert the king's Hollow Bastion OS, which he used to re-install the malicious MCP and record his secret research in a follow-up to Ansem's Report. These experiments generated creatures which Xehanort named "Pureblood Heartless". Excited, the apprentices provided the Heartless with victims to see how they would react, discovering that the Heartless multiplied after consuming their victims' hearts, which led them to believe that these Heartless were in fact manifestations of the darkness within hearts. Further investigations with the Heartless led them to discover Radiant Garden's Keyhole beneath the castle in the form of a door which Xehanort somehow opened. They deduced that it contained the world's heart and allowed the Heartless to tamper with it, causing the walls between worlds to begin deteriorating in a shower of Gummi Blocks. The apprentices began to study these blocks, while simultaneously converting the Chamber of Repose into a Heartless Manufactory which used the Pureblood Heartless to create new, synthetic Heartless, which Xehanort branded with an insignia and named "Emblem Heartless".They attempted to control their subjects' minds and convince them to renounce their sense of self, but this caused the subjects hearts to collapse, so they imprisoned the stricken victims under the castle.
Xehanort and the apprentices presented Ansem with some of the results of their research, such as the existence of the Heartless and the door beneath the castle. However, Ansem suspected that the experiment was connected to the increased instability of the worlds, and his suspicions eventually led him to discover that his apprentices had been abducting test subjects. Distraught, he ordered them to cease the experiment and destroy their research, then sealed off the laboratory.
Shortly afterward, King Mickey arrived at Radiant Garden via Gummi Ship, seeking the source of the darkness that had begun to threaten the worlds. Ansem and Mickey had a long conversation in his study about the Keyblade, the Gummi Ship, and the stability of the worlds, upon which an intrigued Xehanort apparently eavesdropped. At the end of the conversation, Xehanort interrupted to request that Ansem reconsider ending their experiments, but was vehemently denied. Frustrated, Xehanort secretly returned to the Ansem's Report, logging the details of Ansem and Mickey's conversation under the pretense that he himself was Ansem. However, on Mickey's advice, Ansem reviewed the research data on the Hollow Bastion OS, discovering Xehanort's additions to his report, and the true depths of his apprentices' depravity. No longer able to conceal themselves, the apprentices banished Ansem to the Realm of Darkness in order to continue their research. Xehanort unsealed the Chamber of Repose, and built a room at the back to hide Aqua's Keyblade Armor and Keyblade.
Wanting to seek out the "world of the Heartless" and gain power over darkness, Xehanort decided to track down the wielder of the Keyblade and the Princesses of Heart. In order to do so, he resolved to cast off his body and become a Heartless himself. By this time, he had regained his Keyblade, and possibly his memories as well. Choosing to bring the other apprentices with him, he steals their hearts while finally abandoning his name and vocally taking that of his erstwhile master, Ansem, to Braig's confusion. In the process, this created the first six members of Organization XIII, as well as their Heartless. Xehanort himself was split into Xemnas and Ansem, Seeker of Darkness, each of which attempted to obtain Kingdom Hearts in their own way.
After inducting Marluxia into the Organization, Braig's Nobody Xigbar drops in on Ienzo's Nobody Zexion at Twilight's View to find out what he knows about Xemnas's private room in the Chamber of Repose, and mentions the experiments Xehanort and the other apprentices once held there.
While attempting to retrieve data on the Heartless and Organization XIII from Ansem's computer, Sora, Donald, and Goofy are sucked into Space Paranoids and meet Tron, who informs them about the history of the Hollow Bastion OS, and asks them to find the password to the D.T.D. dataspace. While investigating Ansem the Wise's study, Sora finds a painting of Xehanort, who they believe to be "Ansem". After returning to Tron and helping him defeat the MCP, Tron informs him of his understanding that "Ansem" was responsible for installing the MCP, but when they return to King Mickey with their findings, he clarifies that the man they believe to be Ansem was actually the apprentice of the true king, Ansem the Wise. Furious, Sora denounces the apprentice as the cause of all the chaos and his friends' suffering.
Shortly afterward, a massive horde of Heartless attack the town, and the friends rush out to investigate. While the castle is empty, Xemnas sneaks in to access the Chamber of Repose, which he unlocks using a password containing the names of Xehanort and the other five apprentices. As he travels to the room he built, he recalls the day Mickey met with Ansem and Xehanort. When Xemnas later appears at the Dark Depths, Mickey recognizes his face as that of Ansem's apprentice, and finally recalls his name, "Xehanort".
When Dilan, Even, Aeleus, Ienzo, and Lea reawaken at the Heartless Manufactory, they quickly realize that Xehanort, Braig, and Isa are missing. Recognizing Xehanort's treachery, Lea resolves to go searching only for Braig and Isa.
Upon his "birth" in Kingdom Hearts Birth by Sleep, Terra-Xehanort appears to retain Master Xehanort's personality, including his knowledge of darkness, thus being a mere younger incarnation of the elderly Keyblade Master. The only difference is the occasional interference by Terra, shown when Terra-Xehanort briefly asks Aqua who he is, and when he is briefly forced to stand still during the subsequent fight with her.
Shortly after Terra-Xehanort is defeated by the Lingering Will, and loses some of his memories, he ends up in Radiant Garden, and begins to question his existence upon meeting Aqua - by strangling her. By the time he is found by Braig, Dilan, and Ansem, he has lost all of his memories entirely—except for the name "Xehanort", although at one point, Braig insinuates that the amnesia is a mere ruse.
As one of Ansem's apprentices, Xehanort appears to have had a very professional and no-nonsense attitude, shown by his determination in his studies. He appeared to be easily annoyed by Braig and was shown to be equally as interested in the darkness of hearts as his original incarnation. Xehanort appeared frustrated when Ansem forbade him from continuing his studies and experiments, and ultimately disobeyed his master. When speaking to Xemnas, Ansem the Wise refers to Xehanort as "foolish" and that any world of his "would be an empire of ignorance".
Terra-Xehanort's appearance is identical to Terra's, only with silver hair, darker skin and yellow eyes. He also bears a striking resemblance to Master Xehanort in his youth, and some of his physical traits are later carried on to Ansem and Xemnas.
As an apprentice under Ansem the Wise, Xehanort wears a white labcoat with rather loose sleeves that is partway zipped down. The coat also has pockets roughly where Xehanort's hips are. He wears black boots that are identical to those worn by Ansem, Xemnas, and the members of Organization XIII, with a white/silver lining along the top and an indentation on the sides. Underneath his coat, Xehanort wears a grey vest overtop a white collar shirt, along with a purple ascot around his neck. During this time, his hair is worn long, with two bangs framing his face. His eyes have gone from yellow to brown and his hair has become whiter in color. His hair also sports three backward-facing spikes, one at the top of his head, and one on either side, just above his ears.
Powers, attacks and magic
As a fusion of Terra and Master Xehanort, Terra-Xehanort is able to use many of both Keyblade wielders' abilities, and combines Master Xehanort's magical prowess with Terra's youthful agility and raw physical strength. Terra-Xehanort uses Master Xehanort's Keyblade to perform techniques like Ars Solum, a fast combo comprised of multiple hits. He can use Meteor and Quake as well, and he is one of the few bosses that is able to heal with Curaga. When in desperate need of power, Terra-Xehanort gains access to the Dark Impulse Command Style, as well as the Dark Volley and Ultima Cannon Shotlocks.
Terra-Xehanort also can call upon his "guardian," a Pureblood Heartless-like symbiote that floats behind him and serves as both his main source of offense and defense. The powerful guardian attacks Terra-Xehanort's enemies with physical blows and dark energy projectiles, and can also take possession of them. Terra-Xehanort's Heartless, Ansem, inherits the ability to summon this guardian.
Terra-Xehanort wields Master Xehanort's Keyblade. The weapon has a spiky shaft, as well as a gleaming eye of darkness near its teeth, which give the Keyblade a battle ax-like appearance. Master Xehanort's Keyblade is black and silver in coloration; it is able to unlock hearts and appears in its wielder's hand in a flash of dark energy. Another eye of darkness appears on the Keyblade's keychain; Terra-Xehanort uses this Keyblade to perform long, powerful combos, as well as several desperation attacks. When Terra-Xehanort loses his memories, he also loses his ability to wield Master Xehanort's Keyblade. A year later, however, he regains the weapon and uses it to unlock Braig's heart.