Five centuries before the events of the movie, Magearna was created using arcane science by Nikola, who also created the Azoth Kingdom's machinery, including a flying fortress that could be activated and powered by Magearna's Soul-Heart. However, the people began fighting over who would claim this power. Shocked that something he wanted to make people happy had led to only violence and pain, Nikola hid Magearna away at the Nebel Plateau, where she met Volcanion. The two became friends, as Magearna was able to fold up to protect herself whenever Volcanion exploded.
In the present, Levi and Cherie found Magearna and captured her on Alva's orders. Volcanion pursued them, intending to get her back, but ended up being frozen and launched from the airship they were on. When Levi and Cherie later presented her to Alva, Volcanion reappeared, and Magearna ended up back with it.
When everyone had arrived at the Nebel Plateau, Alva and his forces struck again, capturing Volcanion and Magearna's friends as well as some of Ash and his friends' Pokémon. Levi and Cherie told Magearna that unless she surrendered, they would electrocute everyone who had been captured, including Ash and Volcanion. Magearna surrendered, and Alva removed her Soul-Heart before throwing her body away, returning to the Azoth Kingdom and using the Soul-Heart to activate Nikola's flying castle.
Noticing that Ash, his friends, Kimia, and Volcanion were approaching aboard Kimia's flying machine, Alva decided to test the castle's weapons, so he tried to fire a laser cannon, only to find that Magearna, still conscious inside the Soul-Heart, was resisting his commands. Once Ash, Kimia, and Volcanion got to the control room, Alva had his Gengar use Mean Look on the Soul-Heart so Magearna would not be able to resist his command before having it fire at the Nebel Plateau. With her home destroyed, Magearna's consciousness faded and Meowth was no longer able to hear her voice. Alva then fired the laser at the Nebel Plateau again, but this time it was blocked by Volcanion and Magearna's friends as well as Squishy, who temporarily took on its Complete Forme.
Once Alva had tried to escape, Ash replaced the Soul-Heart, only to find that she appears to have lost her memory and personality because of Alva forcing her to destroy her home. Once everyone had escaped and Volcanion had destroyed the castle, Volcanion was revealed to have survived the blast and fallen into a lake. Realizing that her friends were all safe, Magearna's personality returned and when Volcanion passed out, Magearna revived it by producing flowers from her arms.