The story begins only days after the conclusion of Taran Wanderer. With winter approaching, Taran and his companion Gurgi return from their wanderings to Caer Dallben after getting news from Kaw the crow that Princess Eilonwy has returned from the Isle of Mona. Indeed, they find her at home, along with her escort King Rhun of Mona and the former giant Glew, who had been magically restored to human size by a potion from Dallben.

Before Taran can propose to Eilonwy, the bard-king Fflewddur Fflam and his mount Llyan arrive with a gravely injured Gwydion, Prince of Don. Servants of Arawn had assaulted them and seized the magical black sword Dyrnwyn. Fflewddur also states that Taran was involved in the ambush, baffling everyone. With Achren's help, the truth is determined: Arawn himself has come from Annuvin to the verge of Caer Dallben in the guise of Taran, in order to lure Gwydion into the ambush.

Because Dyrnwyn may be pivotal as a threat to Arawn, Dallben consults the oracular pig Hen Wen to determine how it may be regained. During the reading, the ash rods used to communicate shatter and the two thirds of Hen Wen's answer are discouraging and vague. When Gwydion heals sufficiently, he sets out with Taran and others to meet with King Smoit. Gwydion insists that he alone should enter Annuvin to seek the sword, but Smoit's Cantrev Cadiffor is on the way. The small party divides, as Rhun and Eilonwy intend to visit the ships of Mona en route.

When Gwydion, Taran, and others reach Caer Cadarn, they are imprisoned by Magg, the treacherous former Chief Steward of Mona, who has entered service with Arawn and taken over the fortress. When Eilonwy approaches with the other party, she detects something amiss and they cautiously send Fflewddur Fflam to the fortress as a bard. After entertaining the soldiers for a night, he returns with the bad news. Then the companions encounter Gwystyl of the Fair Folk outside the stronghold, en route home after closing the waypost near Annuvin, personally bearing final observations to King Eiddileg about preparations for war by Arawn's forces. With Gwystyl's assistance and store of magical smokes, fires, and concealments, the companions break in and free the prisoners. The plan goes awry, however; King Smoit and his men are finally able to regain control only by Rhun's intervention, which costs his life.

Learning from Gwystyl of the activities in Annuvin, Gwydion turns from the quest for Dyrnwyn to planning for battle at Caer Dathyl. Gwystyl, Fflewddur, and Taran leave to gather support, respectively from the Fair Folk, the northern realms, and the Free Commots. Kaw, sent out by Taran to reconnoiter the enemy, is attacked by Gwythaints while spying near Annuvin, but manages to reach Medwyn, who asks all the creatures of air and land to oppose the forces of Arawn. Taran, Coll, Eilonwy, and Gurgi muster the Commots, who rally to their friendship with Taran, and sends them marching in groups to Caer Dathyl while the smiths and weavers rallied by Hevydd and Dwyvach work day and night to equip them.

Soon after Taran and the last Commots reach Caer Dathyl, King Pryderi arrives from the western realms. In council he announces his new allegiance to Arawn, for the good of all, because "Arawn will do what the Sons of Don have failed to do: Make an end of endless wars among the cantrevs, and bring peace where there was none before." He is rejected utterly but permitted to return unharmed to his army, and at the next day the battle begins. Although the Sons of Don and allies initially have the best of it, the Cauldron-Born arrive en masse before evening, overwhelming the allies and razing Caer Dathyl to the ground.

With High King Math killed, Gwydion is proclaimed the new High King. With the bulk of the Cauldron-Born deployed outside of Annuvin, Gwydion determines that the best chance is to attack while it is guarded by mortal men alone. He will lead the Sons of Don to waiting ships on the north coast and attack by sea, while Taran leads the Commots to delay the Cauldron-Born's return march, as their power wanes with time and distance from Annuvin.

Taran and his army are able to hold the tired Cauldron-Born warriors beyond arm's length by brute force, and turn the march from a straight and easy route into the rugged hills, although Coll dies in battle. Thanks to a company of Fair Folk, and to the animals sent by Medwyn, they destroy most of the Huntsmen who accompany and lead the undead. At last the Cauldron-Born break free of the hills and return to the lowland route. Regaining strength as they near Annuvin, it would be futile for the exhausted allies to meet them head-on again, so inevitably they take the long, easy route to Arawn's stronghold.

Taran and the remainder of his army finally reach Annuvin by a combination of the direct route, a mountain path of Doli's, and a secret pass over Mount Dragon shown to them by Achren. Taran sees that victory is nearly in Gwydion's hands, but also that the Cauldron-Born are about to reach Annuvin. In his alarm, Taran nearly falls off Mount Dragon, but is saved by the now-grown Gwythaint he had rescued so many years ago (The Book of Three). In a desperate attempt to fight off a group of Cauldron-Born who have discovered him on the mountain, he rolls a rock at them, and discovers Dyrnwyn in the hollow the stone occupied. Wielding Dyrnwyn, Taran slays the undead warrior who approaches to slay him, and at that instant all of the Cauldron-Born die as one.

Taran's group enters the fray, and the battle continues through the halls of Annuvin. Taran is almost deceived by Arawn - who has taken the guise of Gwydion - into giving up the sword. After the chaotic defeat of Arawn's forces, the companions gather before the Great Hall. Achren identifies Arawn in the form of a nearby serpent preparing to strike Taran and grabs him. He strikes her fatally, but Taran kills him with Dyrnwyn. With the death of Arawn, the stronghold of Annuvin bursts in flame and falls in ruins, destroying all of the magical implements inside; only Gurgi manages to save several scrolls containing knowledge of farming, smithing, and other crafts. The sword Dyrnwyn begins to fade, losing its magic.

The allies travel to Caer Dallben, where Gwydion tells them that in victory the Sons of Don, with all kinsmen and kinswomen, must return to the Summer Country. Indeed, all those who still have magic will depart, and the Fair Folk and Medwyn have closed their realms to outsiders. Dallben and Eilonwy must also go, and others who have served well, Taran among them, are given the chance to accompany them. Taran proposes to Eilonwy at last, and she accepts.

The Sons of Don plan to leave the next day. However, Taran becomes uncomfortable about his decision overnight. The witches Orddu, Orwen and Orgoch appear before him and reveal that they too are departing, and leave him with an unfinished tapestry depicting his life. He realizes there is much work to be done to rebuild Prydain, and he has made many promises; so he determines to remain behind. Eilonwy is able to willingly give up her magical nature in order to remain with him, and the two are married.

Dallben reveals that with this last quest, Taran has completed a path prophesied in the Book of Three whereby an orphan of "no station in life" would succeed the Sons of Don as High King. Dallben had traveled to seek such a one and try to hasten the day of Arawn's defeat; on this journey, he found a baby, hidden in the trees beside a battlefield and without any token of parentage, and took it in under the name Taran. Taran receives many gifts, including The Book of Three itself, although its powers, like all magic in Prydain, have also faded away with Arawn's demise, leaving it only as a mere chronicle of Taran's life. With Eilonwy by his side, Taran accepts his new responsibility and is hailed by his friends and battle companions as the new High King.
In this reference text summarizing plot of the book The High King, how did the sword Dyrnwyn lose its power?
When Taran killed Arawn with Dyrnwyn in the stronghold of Annuvin, all magical implements inside were destroyed - Dyrnwyn also lost its magic.