In the legendary past, before the creation of Poké Balls, an aura-guiding hero Pokémon named Lucario sensed two armies about to clash at Cameron Palace in Kanto. He told his master, Sir Aaron, while he was being attacked by a group of Houndoom. During the battle, Lucario was blinded, and he used his Aura Sphere to eliminate the Houndoom.
The Queen of Cameron, Lady Rin, decided to die with her people, and so Aaron got on his Pidgeot and traveled to the Tree of Beginning, but they were attacked by a rival group of Skarmory. Later, Lucario arrived by sensing his master’s Aura. When Lucario tried to go with him Aaron sealed Lucario in his staff. Pidgeot returned to the queen with only Sir Aaron’s staff, and the queen realized that Sir Aaron must have sacrificed himself by using his own aura to stop the war. Since then he was revered as a hero, and only his staff remained for his legacy.
Many years later, Ash, Pikachu, Brock, May and Max arrive at Cameron Palace to celebrate the life of Sir Aaron. Ash competes in the Pokémon competition, and wins against a trainer named Kidd and her Weavile. That night there is a royal ball, and Ash is rewarded with the Hero’s Chair and the privilege to hold Sir Aaron’s staff. Team Rocket join the dance too, but Meowth runs off to follow Kidd, who reveals herself as an Agent seeking to capture a Mew.
The Pokémon run off into the attic to play. However, Kidd’s two Weavile attack when Mew joins in. Mew teleports away with Pikachu and Meowth, and Max finds out what happened. In the ballroom, Ash watches fireworks, unaware of what is happening to the Pokémon. Suddenly, Lucario is freed from the staff probably because of Ash having a resemblance to Sir Aaron’s aura. Lucario was confused of what has happened since the time he was sealed and seek to search for answers.
Max informs the rest of the group that Pikachu and Meowth have been taken; Team Rocket overhear him. Lady Ilene, the current queen, says Mew has a tradition of showing up at the palace and taking toys to its home at the Tree of Beginning. Ash and the rest (including Kidd, who Brock finally realizes is famous) head off to the Tree of Beginning with the help of Lucario (Team Rocket follows by hiding in Kidd’s trunk).
On their journey, they find a Time Flower (which allows the finder to look at images of the past) and meet a Bonsly which hitches a ride with the team. That night, Ash recalls how much he and Pikachu have been through, like in the first episode when a flock of Spearow attacked him and Pikachu leaped in and shocked them, saving Ash. Lucario scoffs at that story, saying humans can never be trusted. Ash gets mad and tackles Lucario, but ends up losing in the brawl, upsetting Lucario far more. Max tries to cheer the Pokémon up with chocolate.
The next morning, Lucario encounters the same area where he was sealed in the staff. A Time Flower reveals Sir Aaron trapped his servant and ran off, making everyone believe Lucario in his point of view of the so-called legend. Ash apologizes to Lucario for his behavior last night and begins to cry; Lucario asks Ash to promise that he will not desert Pikachu.
At that moment, Regirock attacks, and everyone runs into the Tree of Beginning. Ash and Lucario split up with May, Max, Brock, and Kidd. Ash ends up getting attacked by Regice, so he and Lucario decide to backtrack. Meanwhile, everyone else is attacked by Registeel, and antibodies produced by the trees are devouring human as if they were a disease. Kidd is the only one who survives.
Ash finally reunites with Pikachu and meets up with Meowth and Kidd. Kidd tells Ash that his friends have been swallowed by the giant cells. Soon, Ash and Kidd get eaten up, while Registeel stops Lucario from saving them. All of Ash’s Pokémon, even Pikachu, cry over their trainers’ deaths. However, Mew decides to talk with the tree, using its powers, and brings everyone back.
Mew, after its performance, becomes ill. Finding that the Tree is dying due to its immune system going into shock, Ash, Kidd, Mew, and Lucario run into the heart of the Tree. They find Sir Aaron in suspended animation, and a Time Flower showing that the legend was true.
Ash uses Sir Aaron’s gloves to help squeeze out his own aura to restore the tree, with Lucario’s help, both knowing they will die in the process. As the aura sphere gets larger and much more powerful, Lucario knocks Ash back and demands to finish the rest. The tree is restored, and Mew is also restored back to health, but Lucario only has little time left. A Time flower is found once again showing Sir Aaron saying goodbye to Lucario as he dies, and sharing that Lucario was more than his pupil, he was his closest friend, and that he hopes to meet Lucario again someday. Lucario begins to cry, seeing his master’s final image, saying to himself that he failed his master. Ash holds Lucario’s paws and says that he proved to be as good a Guardian of Aura as Sir Aaron. Lucario then dies, thanking Ash for encouragement, and goes to see his friend.
Ash and Kidd meet May, Brock, and Max outside, who realize Lucario is not with them. Brock mentions it is hard to believe Lucario is gone, but Ash says, “He isn’t gone… his aura is with me”.
In the credits sequence, it is shown that Ash and co. return to the palace and are rewarded by Lady Ilene; Lucario and Sir Aaron share a chocolate bar in their distant place after death; Kidd leaves and meets with Butler and Diane from a previous film; and Ash and his friends continue their journey.