The youth Taran lives at Caer Dallben with his guardians, the ancient enchanter Dallben and the farmer and retired soldier Coll. He is dissatisfied with his life, and longs to become a great hero like the High Prince Gwydion. Due to the threat posed by a warlord known as the Horned King, Taran is forbidden from leaving the farm and charged with the care of Hen Wen, the oracular white pig. When the pig escapes, Taran follows her into the forbidden forest. After a long, fruitless chase he is attacked by a host of horsemen galloping toward his home, led by the Horned King himself. He manages to escape, but drops, wounded, to the ground. He awakes to find his wound treated by none other than Gwydion, the crown prince in Prydain's ruling House of Dôn, who has been traveling to Caer Dallben to consult Hen Wen. Gwydion, determined to find the pig, takes Taran along with him. Led by Gurgi, a hairy humanoid living in the forest, they reach the Horned King's camp, and learn that his target will be Caer Dathyl, the home castle of the House of Dôn. Gwydion determines to warn the royal court, but the group is attacked by the deathless and powerful Cauldron-Born soldiers, who capture Gwydion and Taran, and take them to Queen Achren in Spiral Castle.
The sorceress asks Gwydion to help her to overthrow Arawn (the powerful Death-Lord who was once her consort) and to join her in ruling Prydain together. When Gwydion refuses, he is imprisoned, but not in the same place as Taran. Princess Eilonwy, who lives in Spiral Castle to learn enchantment from her self-proclaimed "aunt" Achren, visits Taran's dungeon cell, and agrees to free first his companion, and then him. While travelling through a labyrinth of tunnels to joinn Gwydion and his horse Melyngar outside the castle, Taran and Eilonwy steal weapons from a death chamber. As they emerge into the woods, Spiral Castle is sheathed in blue light and collapses, because the death chamber they looted was the High King Rhitta's , and the weapon Eilonwy has taken is the legendary sword Dyrnwyn. Eilonwy has also misunderstood Taran's request, for the man waiting outside is not Gwydion, but another former prisoner of the castle: Fflewddur Fflam, a king by birth but a wandering bard by choice. The three search the ruins, then mourn Gwydion's death, and decide to take up his task to warn Caer Dathyl.
Rejoined by Gurgi, but pursued by the Cauldron-Born, the group is driven far east of their northward course, and ends up into the underwater realm of the Fair Folk who have rescued Hen Wen. The Fair Folk's King Eiddileg grudgingly agrees to let Taran have her back, to re-equip their party, and to provide a guide, a dwarf called Doli. On their journey to Caer Dathyl, against Fflewddur and Doli's advice, Taran rescues an injured fledgling gwythaint, one of the great birds of prey that Arawn has enslaved, to use as his "eyes". The gwythaint recovers quickly and escapes overnight, shortly followed by Hen Wen, who flees just before the Horned King's army spots them all. Fflewddur, Doli and Gurgi stand to fight, while Taran and Eilonwy go ahead on Melyngar chased by the Horned King. On the top of a hill, he attacks them, and breaks the boy's sword on the first blow. Taran seizes Dyrnwyn from Eilonwy, but lacks the "noble birth" needed to draw it. White flame burns his arm, and throws him to the ground. Just before losing consciousness, he sees another man in the trees and hears an unintelligible word. The Horned King's mask melts and he bursts into flame.
When Taran wakens in bed, he learns that the man who destroyed the Horned King was Gwydion, who had been with Achren at another stronghold when Spiral Castle fell. He has learned to understand the hearts of all creatures, and was able to communicate first with the gwythaint, and then with Hen Wen. From the oracular pig he learned how to destroy the Horned King, by saying his secret name. Recognizing his nobility, Eilonwy has given Dyrnwyn to him, while Taran and his companions are to receive treasures from Caer Dathyl in recognition of service to the House of Dôn. Eilonwy gets a ring made by the Fair Folk, Gurgi a wallet of food that cannot be depleted, Fflewddur a golden harp string that can never break, Doli the ability to turn invisible (which he unusually lacks). Taran -who in the course of his adventures has realized that Caer Dallben is where he most wants to be- asks only to return home, and Gwydion accompanies him personally, along with Eilonwy and Gurgi who are now homeless.