As a wild Pokémon
Xerxer debuted in PS549. It, along with Yveltal, first appeared in Vaniville Town, where they began battling each other. Their clash caused much destruction, forcing the townspeople who lived there to run away in order to escape from harms way. The two Legendary Pokémon were sought after by Team Flare, who intended to use one of them to power their ultimate weapon. After some time, Xerneas and Yveltal stopped fighting and disappeared. With their influence over the media, Team Flare reported that the destruction was caused by a large explosion.
In What Does Charmander Do When It Dozes?, Xerosic discovered that after the battle ended, Xerneas retreated to Route 8, where it reverted to the form of a large tree. By mind controlling the townspeople captured from Vaniville Town, Celosia led an operation to retrieve Xerneas and take it to the Team Flare Secret HQ. When X and his friends learned of this operation, they battled Team Flare in an attempt to stop it. Despite their best efforts and success in freeing the Vaniville townspeople, Xerneas was captured by Team Flare and taken to their base. There, it was transported to the ultimate weapon's control room so that its life energy would be drained to power the ultimate weapon.
X, feeling guilty for Team Flare obtaining Xerneas, went to Geosenge Town alone after learning that the Team Flare Secret HQ was located there. Upon arriving, he infiltrated the base with Emma, who had tagged along, but accidentally stepped on a warp tile that sent him to the ultimate weapon's control room. There, X met Lysandre, the boss of Team Flare, and battled him in order to prevent the ultimate weapon from being activated. By using his Élec's Lightning Rod, X drained the ultimate weapon of its electricity in an attempt to weaken it. As the battle continued, X's efforts led to Xerneas awakening from its dormant tree form. Despite this, Lysandre was unconcerned due to Xerneas being in its Neutral Mode and had the ultimate weapon activated anyway.
After learning that X had gone off alone, Y, her friends, and the Kalos Gym Leaders all traveled to Geosenge Town to assist X. Upon arriving, they found the ultimate weapon in the process of being unearthed. Y and the Gym Leaders all tried to keep the ultimate weapon from opening while Trevor, Tierno, and Shauna went to the Secret HQ to help X. There, they met AZ, the former king of Kalos who created the ultimate weapon. After freeing AZ from his jail cell, Trevor's group arrived at the control room, only to find that Lysandre had already beaten X. Trevor, Tierno, and Shauna attempt to remove the ultimate weapon's key from its control module, but are unable to do so before the weapon fires on the Kalos region. When AZ notes that the destruction caused by the weapon means the events 3000 years prior have repeated, Xerneas tells him that things are different, as there is a human that it wishes to lend its power to.
Despite the ultimate weapon's successful activation, the combined effort of X, Y, their friends, and the Gym Leaders weakened the weapon's blast so that no innocent lives were taken. As AZ is captured by Xerosic, he has Xerneas take X and his friends back to the surface. After breaking through the ceiling, Xerneas begins looking for a human to lend its power to. Y decides to become Xerneas's Trainer and gives it the nickname Xerxer. Bryony leads a group of Team Flare Grunts in an attempt to recapture Xerxer, but Y commands it to defeat them all with ease. With no more obstacles, Y attempts to destroy the ultimate weapon, but is stopped by the arrival of Malva, who had captured Yveltal. Malva reveals that when Xerxer went into its tree form, Yveltal hid underground and went dormant underneath Xerxer in the form of a cocoon. Y and Malva battle each other briefly, but are stopped by Xerosic, who warns the two that if Xerxer and Yveltal battle, it will lead to an endless battle due to their evenly matched power. With no choice but to not fight, Y and her friends decide to retreat and fly away on Xerxer.
In Pinsir Changes, at Anistar City, Essentia battled Y in an attempt to steal Xerxer. With her Expansion Suit's Poké Ball Jack function, Essentia began uploading a virus into Y's Poké Ball in order to put Xerxer under her control. By disguising herself as a nurse, Essentia lured Y into a false sense of security and knocked her unconscious, allowing Essentia to take Xerxer's Poké Ball. Afterward, Essentia disguised herself as Y and attempted to fool X, only for him to easily see through the trick and break the disguise. Y arrived soon after, having been found and awakened by her friends. By Mega Evolving Solsol and Rute, Y and X battled Essentia in order to take Xerxer back.
During the battle, Essentia was unable to fully control Xerxer, which she attributed to Xerxer's status as a Legendary Pokémon. The battle was interrupted by the arrival of Zygarde, which began attacking everyone, forcing Essentia to turn her attention towards it in order to capture it. Although she succeeds in capturing Zygarde and escaping, the event put Xerxer back to Y's control. The event left Xerxer exhausted, forcing it to return to its tree form.
In Yveltal Steals, after learning where Team Flare had gone into hiding, Y and her friends traveled to the Pokémon Village in order to stop the villains. On their way, Blue was attacked by Yveltal, which had appeared without Malva. Just before Yveltal's attacks could hit Blue, he was saved by Y, who had Xerxer block the attack with its horns. Xerxer told Y and the others to go on ahead to the village while it stayed behind to fight with Yveltal. Although worried that Xerxer may be at a disadvantage due to its weakened state, Xerxer assured Y and her friends that it would be fine.
Later, after Trevor, Tierno, and Shauna finished their battles with the Team Flare scientists, they found that Xerxer and Yveltal were still in battle, but had stopped moving. Xerxer told everyone that Zygarde is the protector of Kalos's ecosystem, which was threatened due to it and Yveltal clashing with each other. It also explained that by it and Yveltal reverting to their dormant tree and cocoon forms, Zygarde would have no reason to stay. As it and Yveltal finished turning to their dormant forms, Xerxer bid farewell to the Vaniville children.
Xerneas appeared in a flashback in PASM30, where Samson Oak discussed how Zygarde appeared to confront it and Yveltal, leaving for Alola once things were settled.