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.
In the Seven Kingdoms
The North / The Riverlands
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, King in the North and is taken prisoner upon its discovery. Robb's army returns to Riverrun, having vanquished Tywin Lannister's armies, and Robb reveals that he has married Jeyne Westerling, invalidating his betrothal 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 Lannister captives (one of them a younger son of Kevan Lannister). 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 mercenaries known as the 'Brave Companions' (now in the service of Roose Bolton) and taken to Harrenhal. The mercenary captain 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, and Jaime risks his own life to rescue her.
Robb's forces dwindle further at the Battle of Duskendale, wherein under the command of Roose Bolton, the eastern half of the Stark's armies 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 Robb's home territory of Winterfell and the Neck, having taken Moat Cailin. 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 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 priest Thoros of Myr: originally sent by Eddard Stark to put down the Lannister raids, and now defending the smallfolk of the Riverlands. The group encounters Sandor Clegane, known as the Hound, and offers him trial by battle, which he wins by killing Lord 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 Frey agrees to forgive Robb if the wedding between Edmure and Roslin takes place. At the wedding celebration, the Boltons and Freys kill Robb's army. Robb is murdered by Roose Bolton, and Catelyn mutilates her own face in grief. One of the Freys cuts her throat, and her body is discarded, naked, into the adjacent river. Robb's corpse is beheaded, and the head of his dire wolf sewn in its place, with his crown nailed to the direwolf's head. 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 'Lord Paramount of the North', in place of House Stark. The crown also legitimizes Roose's bastard son Ramsay Snow, under the name of 'Ramsay Bolton', as 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 of the book, a re-animated but decayed and mutilated Catelyn is leading the Brotherhood Without Banners and oversees the lynching of two Freys present at the Red Wedding.
The South / King's Landing
After the Battle of the Blackwater, Davos Seaworth is taken to Dragonstone by men loyal to King Stannis. Davos blames the 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. (Chronologically, this happens shortly before the Red Wedding.)
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. Balon Greyjoy offers an alliance on the conditions that he rules the Iron Islands and the North as a separate kingdom, but Tywin refuses.
Word reaches King's Landing of the sudden death of 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 reveals 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, and Tyrion framed for the murder, whereupon his sister Cersei Lannister places Tyrion on trial. Sansa is smuggled out of the castle by the jester Dontos, and taken to Lord Petyr "Littlefinger" Baelish, who has Dontos killed and admits culpability in Joffrey's death and Tyrion's framing, incriminating several of the Tyrell family as well. Littlefinger, with Sansa, departs King's Landing for the Eyrie, scheming to marry Lysa Arryn, Catelyn's sister, 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 convinces Stannis to sacrifice Edric Storm, a bastard son of Stannis's late brother King Robert Baratheon, to wake the dragons, but Davos smuggles Edric 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 for Joffrey's murder; 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. 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, and nearly emerges victorious, but dies in the duel. Tyrion is again condemned to death but is freed by Jaime and Varys. Jaime reveals that Tyrion's first wife Tysha was a crofter's daughter, not a prostitute as Tywin told him; wherefore Tyrion swears revenge on Jaime, Cersei, and Tywin and tells Jaime 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. 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. He also tells her that he had killed the former King Aerys II Targaryen because he planned to burn the city and its inhabitants to spite Robert Baratheon. He then leaves king's landing, angry at Cersei for her relations with other men.
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, 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. Petyr subsequently pushes Lysa to her death.
On the Wall
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 monsters known as 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 captive 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, Ygritte murders the man, calling Jon a coward. Jon, with the assistance of Bran's direwolf (Bran and company are hiding in a nearby abandoned tower), kills many of the wildlings and escapes to Castle Black, ahead of the wildling force. The approaching army reaches Castle Black and assaults the Wall; but Jon takes command of the defenses and repels several assaults, and 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 principal wildling camp, the surviving army of King Stannis arrives, 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's offer. Before he can inform Stannis, Jon is chosen by the Night's Watch as its new Lord Commander.
In the East
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 the cargo of her three ships, the ships themselves, and Drogon (the largest and strongest dragon), 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 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 has 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 was murdered by a former butcher called Cleon, styling himself King Cleon the Great, she decides to rule Meereen in practice for the rule of Westeros.