A Storm of Swords picks up the story slightly before the end of its predecessor, A Clash of Kings . The Seven Kingdoms of Westeros are still in the grip of the War of the Five Kings , wherein Robb Stark, Balon Greyjoy, Joffrey Baratheon, and Stannis Baratheon compete for the Iron Throne. Meanwhile, a large host of wildlings approach the Wall under the leadership of Mance Rayder, the self-proclaimed "King Beyond the Wall", with only the undermanned Night's Watch in opposition. Finally, Daenerys Targaryen approaches Pentos.
At Riverrun, Catelyn Stark offers the captive Jaime Lannister his freedom in exchange for Catelyn's daughters, Sansa and Arya, who Catelyn believes are held by the Lannisters in King's Landing. Jaime is sent south, escorted by Brienne of Tarth. Catelyn makes this deal without the approval of her son Robb, the King in the North, and is taken prisoner upon its discovery. Robb's army returns to Riverrun, having vanquished Tywin Lannister's armies in the Westerlands, and Robb reveals that he has married Jeyne Westerling, invalidating his promise to be wed to a daughter of House Frey. Jaime's release infuriates Lord Rickard Karstark, whose two sons Eddard and Torrhen had been killed by Jaime in battle; and in revenge, Karstark kills two young Lannister captives. To secure his authority and atone for these deaths (thus preventing the Lannisters from executing Stark prisoners), Robb executes Lord Rickard, losing the support of House Karstark as a result.
Jaime and Brienne are waylaid by the Brave Companions (now in the service of Roose Bolton) and taken to Harrenhal. Their captain Vargo Hoat orders Jaime's sword hand cut off, hoping the blame will be placed on Bolton, but Jaime is sent to King's Landing after he assures Lord Bolton he will absolve him to his father. Brienne is thrown into a bear pit by Hoat, and Jaime risks his own life to rescue her. He also tells her that he had killed the former King Aerys II Targaryen because he planned to burn the city and its inhabitants with wildfire to spite Robert Baratheon.
Robb's forces dwindle further at the Battle of Duskendale, wherein the eastern half of the Stark's armies, under the command of Roose Bolton, are ambushed by a joint army under Gregor Clegane and Lord Randyll Tarly. More losses are taken as the army retreats. Meanwhile, the Greyjoys now hold the Neck, having taken Moat Cailin, thus barring Robb from returning to his homeland. To recapture Moat Cailin from the Greyjoys, Robb relies on the support of the Freys. When Lord Hoster Tully dies, Catelyn's brother Edmure becomes Lord of Riverrun and Lord Paramount of the Trident. Robb gains renewed hope when he learns that Balon Greyjoy has died in a fall from a bridge, whereafter two of Balon's brothers, as well as his daughter Asha, vie to succeed him. The Freys propose a wedding between Edmure and Roslin Frey, one of Lord Walder Frey's daughters, to compensate for the loss of Robb's marriage.
Arya Stark and her friends encounter the "Brotherhood Without Banners", led by Lord Beric Dondarrion and the red priest Thoros of Myr: originally sent by Eddard Stark to put down the Lannister raids, the band now defends the smallfolk of the Riverlands. The group encounters Sandor Clegane, known as the Hound, who abandoned Joffrey during the Battle of the Blackwater, and offers him trial by battle, which he wins by killing Beric, but Thoros resurrects Beric thereafter. Arya is kidnapped by the Hound for ransom, and they proceed to Riverrun. On their journey, they discover that Robb and Catelyn will be at Edmure's wedding at the Frey bridge-stronghold The Twins, and change their destination accordingly.
Robb Stark's army reaches the Twins, where Walder agrees to forgive Robb if the wedding between Edmure and Roslin takes place. At the wedding celebration, the Boltons and Freys turn on the Stark soldiers, massacring the Stark forces. Robb is murdered by Roose Bolton, while Catelyn has her throat cut by Raymund Frey and her body is thrown into the adjacent river. Many of the northern lords are killed, and the survivors captured. Edmure, after consummating his marriage, is kept as a hostage. These events become known as the Red Wedding.
It is thereafter revealed that Roose Bolton engineered the defeat at Duskendale by sending Robb's soldiers into a trap set by the Lannisters, while holding his own forces in reserve, and arranging that all but his own forces would be slaughtered in rearguard. The combined effect was to kill off the forces of other Northern houses loyal to Robb while leaving the Bolton army unscathed. Tywin Lannister (the King's Hand and grandfather) rewards Roose by naming House Bolton the Great House of the North, in place of House Stark. The crown also legitimizes Roose's bastard son Ramsay Snow as a Bolton and the new Lord of Winterfell.
Arya and the Hound arrive at the outskirts of the castle as the Red Wedding is taking place; to keep her from running inside to her death, the Hound knocks Arya unconscious and takes her downriver. As she sleeps, Arya sees through the eyes of her long-missing direwolf, Nymeria, that her mother Catelyn is dead. Arya and the Hound encounter Gregor Clegane's men, by whom the Hound is wounded. His wound becomes infected, and Arya abandons him. She finds a ship from the Free City of Braavos, but the captain refuses her passage until she offers him the coin and password "Valar Morghulis", given to her by Jaqen H'ghar. The captain replies "Valar Dohaeris", and they set sail for Braavos.
In the epilogue, a re-animated but decayed and mutilated Catelyn, now under the name Lady Stoneheart, is leading the Brotherhood Without Banners, Beric having given his life to resurrect her, and she oversees the lynching of two Freys present at the Red Wedding.
After the Battle of the Blackwater, Davos Seaworth is taken to Dragonstone by men loyal to King Stannis. Davos blames the red priestess Melisandre for Stannis's defeat, and is imprisoned for treason (Melisandre having foreseen his intention to assassinate her). At Melisandre's behest, Stannis releases Davos and asks him to serve as his Hand. With Stannis' cooperation, Melisandre has performed rituals to awaken "stone dragons", which she identifies as the great statues adjacent to the castle.
King's Landing welcomes the Tyrells as liberators, and King Joffrey sets aside his betrothal to Sansa Stark in favor of Margaery Tyrell. Sansa is soon compelled to marry Tyrion Lannister, who refuses to consummate the marriage against her will.
Word reaches King's Landing of the sudden death of Balon Greyjoy, followed by news of the Red Wedding. Joffrey gloats that he has "won" the war; whereas the governing Small Council is shocked to learn that Tywin secretly masterminded the Red Wedding. Tyrion warns his father that the defeated Northerners will not quietly submit to Bolton rule, but Tywin dismisses his warning. Later, Tyrion realizes that Joffrey sent the assassin who attempted to kill Bran Stark at Winterfell, and thus set the war in motion.
Margaery and Joffrey's wedding is held as planned, but during the ensuing festivities, King Joffrey is poisoned. Tyrion is accused of the murder by his sister Cersei Lannister and placed on trial. Sansa is smuggled out of the castle by the jester Dontos Hollard, and taken to Lord Petyr "Littlefinger" Baelish, who has Dontos killed and admits culpability in Joffrey's death and Tyrion's framing, incriminating Margaery's grandmother Olenna Tyrell as well. Littlefinger and Sansa departs King's Landing for the Eyrie, Littlefinger scheming to marry Catelyn's sister Lysa Arryn with the blessing of the Small Council to gain the support of House Arryn.
Davos discovers a request by the Night's Watch for aid against Mance Rayder and the Others. Melisandre tries to persuade Stannis to sacrifice Edric Storm, a bastard son of Stannis' late brother King Robert Baratheon, to wake the dragons. Stannis is reluctant, though he uses Edric's blood in leeches to curse the three rival Kings. After Balon, Robb and Joffrey die, apparently proving the power of King's blood, Davos has Edric smuggled to safety. Stannis prepares to execute Davos for treason but is prevented when Davos shows Stannis the Night's Watch's plea.
Jaime and Brienne reach King's Landing to find that Joffrey's younger brother Tommen Baratheon will inherit the throne; Tyrion is on trial; and the Tyrell bannermen blame Brienne for Renly Baratheon's death. Jaime's severed right hand becomes infected, but he is healed by former maester Qyburn, earning Qyburn the admiration of Cersei. Jaime refuses to believe that Tyrion killed Joffrey, rejects Cersei's advances, and becomes Lord Commander of the Kingsguard, but refuses his father's offer of Casterly Rock, whereupon Tywin disinherits him. Jaime frees Brienne and gives her a sword reforged from Ice, Ned Stark's sword. He tells her to keep her oath to Catelyn, to find Arya and Sansa and return them home. Against Tyrion, Cersei recruits the spymaster Varys and Tyrion's lover, Shae. Tyrion is approached by Prince Oberyn Martell of Dorne, who offers a trial by combat against Cersei's champion, Gregor Clegane, who he knows was responsible for the death of his sister Elia. Oberyn nearly emerges victorious, but is ultimately killed by Gregor, although the poison on Oberyn's spear leaves Gregor dying in agony. Tyrion is again condemned to death but is freed by Jaime and Varys. Jaime reveals that Tyrion's first wife Tysha was not a prostitute as Tywin told him, and genuinely loved Tyrion. Outraged, Tyrion swears revenge on Jaime, Cersei, and Tywin, and tells Jaime he murdered Joffrey and that Cersei took other lovers while he was Robb Stark's captive. During Tyrion's escape, he strangles Shae and kills Tywin in his privy before fleeing Westeros.
At the Eyrie, Littlefinger and Lysa are married, and Sansa remains hidden by pretending to be an illegitimate daughter of Littlefinger's, named Alayne Stone. Lysa reveals that Littlefinger had convinced her to poison Jon Arryn, her late husband, to prevent her son from being fostered to Stannis Baratheon, and to write to Catelyn that Arryn had been poisoned by the Lannisters, which was the catalyst for the events of A Game of Thrones . Lysa threatens to kill Sansa, thinking she is trying to seduce Littlefinger, but Littlefinger intervenes and, after revealing that he had only ever loved Catelyn, pushes Lysa to her death.
The detachment of the Night's Watch under Lord Commander Jeor Mormont awaits word from Qhorin Halfhand and Jon Snow at their forward base. The Watch are attacked by undead wights and the Others, suffering heavy casualties; but Samwell Tarly kills one of the Others with a blade of dragonglass. Some of the Watch mutiny and kill Mormont, but Sam escapes with the help of one of Craster's daughter-wives, Gilly, and they and the girl's newborn child approach the Wall, assisted by a strange figure riding an elk, whom Sam calls Coldhands. Among the dead are most of the Watch's senior leadership.
Bran Stark, his servant Hodor, Jojen and Meera Reed are guided north by Bran's dreams of a three-eyed crow. At the Wall, Sam guides them to Coldhands and returns to Castle Black, having sworn to keep Bran's survival secret even from Jon.
Jon convinces Mance that he is a deserter from the Night's Watch and learns that the Others are driving the wildlings south towards the Wall. Jon and his captor Ygritte also begin a sexual relationship. Mance seeks the legendary Horn of Winter to shatter the Wall. After climbing the Wall, the wildlings press Jon to murder a homeless man. When Jon refuses, the wildlings turn on him but Jon, with the assistance of Bran's direwolf Summer (Bran and company are hiding in a nearby abandoned tower), kills many of the wildlings and escapes to Castle Black. The approaching wildling army reaches Castle Black and assaults the Wall; but Jon takes command of the defenses and repels several assaults, during which Ygritte is slain. After that, Janos Slynt and Alliser Thorne imprison Jon for treachery and subsequently send him north of the Wall to kill Mance under a pretense of parley. As Jon is talking with Mance in the wildling camp, the army of King Stannis arrives, routing the Wildlings, and Mance is imprisoned. Melisandre believes the wildling invasion to portend the return of the Great Other, the sworn foe of her god R'hllor. Stannis offers to legitimize Jon and make him Lord of Winterfell in exchange for his support, but when his direwolf Ghost unexpectedly returns, Jon decides to decline Stannis' offer. Before he can inform Stannis, Jon is chosen by the Night's Watch as its new Lord Commander.
Heading for Pentos by sea, Daenerys Targaryen learns that large slave armies can be bought in the cities of Slaver's Bay, and exchanges one of her infant dragons for the entire host of the warrior-eunuch Unsullied. Upon payment, which includes Drogon (the largest and strongest of her dragons), Daenerys orders the Unsullied to turn on their former masters and sack the city. With the help of her maturing dragons, she frees all the slaves of Astapor. Daenerys' horde then conquers the slaver city of Yunkai; but the lords of neighbouring Meereen antagonize Daenerys by killing child slaves and burning the land to deny her resources. Consequently, Daenerys besieges the city to no avail.
Daenerys discovers two traitors in her camp: Ser Jorah Mormont, who had spied on her for Varys, informant to the late King Robert Baratheon, in exchange for a royal pardon; and Arstan Whitebeard, an alias of Ser Barristan Selmy, the humiliated former Lord Commander of Robert Baratheon's Kingsguard. Daenerys offers both men the chance to make amends by sneaking into Meereen to free the slaves and start an uprising. Meereen soon falls and, in retaliation for the murdered child slaves, Daenerys has the city's rulers put to death. Selmy asks for Daenerys' forgiveness and becomes Lord Commander of her Queensguard while Jorah, who refuses to admit any wrong, is banished. When Daenerys learns that the council she left in Astapor has been overthrown, she decides to rule Meereen in practice for the rule of Westeros.