The Tree of Beginning's antibodies consume all the trainers, however the devastation of the Pokmeon convinces Mew to restore them. However, this sends the Tree into shock and it begins to break apart, with the Pokemon living in the tree at risk and Mew left close to death.
Ash and Lucario go to the central core of the Tree only to find that Sir Aaron had sacrificed himself there by using all his Aura to stop the war. Lucario stops Ash from using all his aura, and dies restoring the Tree.
Sir Aaron and Lucario are then shown reuniting in the afterlife.
Thanks Mark I!