The third and final book in Chris Colfer's
A Tale of Magic… series opens with a mysterious prologue: Deep beneath the earth, a woman who has waited "several lifetimes" orders her companion to open enormous iron doors at the bottom of a miles-long tunnel, revealing the gates of the underworld.
Nearly a year has passed since Prince "Seven" Gallivant seized the Southern Kingdom and declared himself emperor of the Righteous Empire. He has replaced the military with an invincible Army of the Dead, outlawed schools, churches, and creative expression, and sentenced anyone who sympathizes with the magical community to death. Brystal Evergreen, the Fairy Godmother, leads a rescue at Seven's coliseum, where he plans to publicly execute over a hundred imprisoned sympathizers. The prisoners turn out to be witches in enchanted disguises, while the executioners reveal themselves as members of the Fairy Council, Brystal's group of allied fairies. Brystal encases the prisoners in floating bubbles and summons gryphons to cover their escape. She and Lucy, a witch with white feathers for hair, sneak into the Chariot Hills Library but find the contents burned. Seven then orders a purge of every remaining book in the Empire.
Brystal's urgency stems from a deal she made with Death itself. After being killed by the Righteous Brotherhood, Seven's anti-magic faction, she bargained for her life: She has one year to find and destroy a woman called the Immortal using a spell from an ancient book, or Death will reclaim her. Brystal also carries a curse of disturbing, intrusive thoughts inflicted by a witch named Mistress Mara. With only two weeks remaining—counted down by a silver pocket watch she keeps on her person—she has secretly accepted that she cannot kill another person to save herself. Instead, she prioritizes finding the book, believing its power can also destroy the Army of the Dead.
Lucy persuades Brystal to visit Madame Weatherberry, their former mentor whose spirit is trapped in a cave in the Northern Mountains alongside the frozen body of the Snow Queen, a monstrous creature Madame Weatherberry inadvertently created from years of suppressed heartbreak. Madame Weatherberry identifies the book as the Book of Sorcery, hidden in the Temple of Knowledge, a location concealed from all maps and protected by deadly challenges. Brystal privately confesses she cannot kill the Immortal. After the girls leave, Madame Weatherberry conceives a plan of her own.
A crisis unfolds when Xanthous, a fairy whose specialty is fire, wakes in the Eastern Kingdom's capital to find his hotel room engulfed in uncontrollable flames, with a threatening message burned into the wall. The fire destroys over half the city. Dr. States, director of the Alchemy Institute, a secret floating campus where scientists combine magic with science, declares the fire a planetary threat and convenes a Conference of Kings. The conference votes nearly unanimously to eliminate Xanthous. Brystal proposes retrieving the Book of Sorcery to strip Xanthous of his powers instead. Dr. States agrees but insists the alchemists will continue hunting Xanthous. Seven demands delegates accompany Brystal, including Lucy, three knights, Gobzella (a goblin warrior), Butternut (a troll), Spanky (a dwarf), and Prince Elron of the Elf Territory.
While hiding in the wilderness, Xanthous discovers the fire erupts only when he touches the ground, even with his magic muted. He meets Elrik Elderwood, a young elf prince who shares his experience of a cruel father, and the two develop romantic feelings. Elrik takes Xanthous to the Elf Territory, where the high elevation keeps him safe. However, King Elvin has secretly agreed to hand Xanthous over to Seven in exchange for sparing his territory. Elrik's sister lures Xanthous into a cage, and dead soldiers transport him to the Righteous Palace, where Seven plans to use him as bait to ambush the Alchemy Institute.
En route to the Temple of Knowledge, the delegates discover a bomb hidden inside Seven's dead soldier. Magic fails inside the protective dome surrounding the temple islands, and the carriage explodes. The three knights are apparently killed, and Brystal loses her wand. The survivors are rescued by Ryder, a sixteen-year-old Caretaker who rides a dragon named Kitty. The islands, called the Dragon Keys, are a sanctuary for over fifty dragon species that serve as the temple's guardians. A water dragon named Goldfish has collected both Brystal's wand and the temple key, which Ryder deduces his mother threw into the ocean to keep hidden.
Inside the temple, the delegates face three challenges. In the physical challenge, they climb shifting stone bricks while magma rises; Butternut falls to his death, and Gobzella saves the rest. In the mental challenge, four doors each lead along a different path to the same destination. Prince Elron, revealing he was sent to steal the book for the elves, rushes through the wrong door and dies. Brystal deduces the destination is death, chooses the longest path, and confirms her choice by noting that her curse steers her away from it. In the emotional challenge, apparitions of each delegate's deepest insecurities trap them in quicksand. Ryder, Lucy, and Gobzella conquer their fears, but Spanky refuses to face his and perishes. Brystal is unaffected, having already defeated her inner demons.
A sorcerer spirit reveals the Book of Sorcery was taken centuries ago by a woman who spent over three hundred years completing the challenges. Using the vault's library, Brystal identifies her as Queen Immortalia, first woman to rule the Eastern Kingdom, whose portrait matches Queen Endustria and Princess Proxima. Since the book is gone, Brystal takes the Hall of Dreams, a collection of bubbles representing humanity's aspirations, intending to use it to spread joy.
Meanwhile, Queen Endustria reveals her true identity to her granddaughter Proxima: She is Immortalia, born into slavery thousands of years ago, who tricked Death into granting her immortality to retrieve the Book of Sorcery and control demons imprisoned at the earth's core. Having opened the demons' gate (the prologue scene), she poisons Proxima, assumes her identity, and marches toward Chariot Hills commanding fire demons.
Events converge at Chariot Hills. Seven fires harpoons to drag the Alchemy Institute down from the sky. Elrik escapes prison and frees Xanthous, who learns from fire demons that he is the heir to the Demon Throne. Emerelda, a member of the Fairy Council, leads the fairies and witches to the Northern Mountains, where Madame Weatherberry has begun defrosting the Snow Queen to counter the demons' fire. Brystal arrives on Kitty. Xanthous and Elrik steal the Book of Sorcery from Immortalia; Xanthous recites the oath of the Demon King, gaining command of the demons. Lucy and Gobzella trap Immortalia. Brystal uses the book to destroy the Army of the Dead permanently but refuses to kill the Immortal.
The Snow Queen rampages into the city. Madame Weatherberry's spirit reveals she made her own deal with Death: Since the Snow Queen's frozen state made them both effectively immortal, Death agreed to spare Brystal's life in exchange for both of their deaths. She begs Brystal to let Kitty destroy the Snow Queen, calling it liberation from an eternity of guilt. Brystal, weeping, complies. Kitty incinerates the Snow Queen, and Madame Weatherberry fades peacefully, telling the fairies, "You are my greatest dreams come true."
In the aftermath, the Righteous Brotherhood is imprisoned. Penny Charming, Seven's cousin, inherits the throne and renames the nation the Charming Kingdom. Seven and Immortalia are confined in the Alchemy Institute. Xanthous accepts his destiny as Demon King, and Elrik chooses to accompany him; they descend into the earth together. Brystal entrusts the Book of Sorcery to Dr. States, who commits to incorporating compassion into the alchemists' work. Brystal's pocket watch stops ticking: Madame Weatherberry's sacrifice has freed her from her countdown, and the story closes with Brystal savoring the realization that she is truly alive.