The Sack of King's Landing was the event that ended Robert's Rebellion and consisted of a devastating assault on the city of King's Landing by the army of House Lannister, after they had been welcomed inside the city gates as allies. Due to this treachery, it was more of a massacre than an actual battle. During the sack, as Lannister soldiers rampaged throughout the city, the Mad King, Aerys II Targaryen, was slain along with most of his loyal retainers and those family members who had not fled to the island of Dragonstone.
As the city was sacked, Ser Jaime Lannister, a member of the Kingsguard, turned on and slew the Mad King, an act of treachery which earned him the name "Kingslayer", even though King Robert later forgave him for this act.
Season 1Catelyn Stark talks to her son Robb about the Sack of King's Landing. She mentions that Tywin Lannister slew the young Targaryen children, referring to the murders of Prince Aegon and Princess Rhaenys, and how he has not gotten any more merciful with age.
Jaime reveals to Brienne that, when his father marched to the gates of King's Landing, both Jaime and Varys advised him not to trust Lord Tywin. Aerys, however, followed Grand Maester's Pycelle counsel and had the city gates opened, allowing the Lannister forces to sack the city. Jaime advised Aerys to surrender, only for the Mad King to demand Jaime his father's head and order Lord Rossart to ignite the caches of wildfire hidden throughout the city to burn it to the ground with all its inhabitants. Jaime then killed Rossart and then Aerys, who kept muttering "burn them all" as he died. Aerys seemingly believed the massive wildfire inferno would also transmute him into a dragon. Afterward, Eddard Stark reached the throne room and found Jaime along with the two corpses.
In the books
In the A Song of Ice and Fire novels, the Sack of King's Landing is described as a particularly brutal and treacherous battle. During Robert's Rebellion, the forces of Houses Stark, Baratheon, Arryn and Tully had fought against those houses owing direct allegiance to House Targaryen, but of the other Great Houses only House Tyrell had sworn themselves to the Mad King's cause, and most of their forces were tied down in the south, besieging the Baratheon stronghold of Storm's End. House Martell of Dorne had reluctantly committed troops to the Targaryen cause only because the Mad King held Princess Elia Martell, the wife of Prince Rhaegar Targaryen, in King's Landing as a virtual hostage. The Martells were insulted by Rhaegar having started the war in the first place by taking Lyanna Stark as a lover, dishonoring his own marriage to Elia.
During the fighting, House Greyjoy refused to take any part and House Lannister similarly sat out the bulk of the war, Lord Tywin having felt insulted by many of the Mad King's own actions in the preceding years, such as the rejection of Cersei to marry Rhaegar and taking Jaime into the Kingsguard. However, after Robert's victory at the Battle of the Trident Tywin rushed his army to King's Landing. In front of the city gates, he proclaimed that the Lannister force had come to defend the city from the rebel army rushing south under Eddard Stark. Following the advice of Grand Maester Pycelle, Aerys had the city gates opened to the 'reinforcements', only for the Lannister troops to betray the city defenders and put them to the sword. The city was brutally sacked, with thousands of smallfolk caught up in the fighting and killed as well as soldiers on both sides.
During the battle, Ser Jaime Lannister killed Lord Rossart and afterward killed the Mad King by stabbing him through the back at the foot of the Iron Throne. Knights loyal to his father burst into the throne room to see the end of the incident, ensuring that Jaime would forever be known as 'the Kingslayer'.
During the closing stages of the battle, Lannister troops scaled Maegor's Holdfast and killed Princess Elia Martell and her two children, Princess Rhaenys Targaryen and Prince Aegon. According to rumor, the dread knight Gregor Clegane performed horrible deeds during this event.
The death of the Mad King and his grandchildren saw the end of Robert's Rebellion and allowed Robert Baratheon to claim the Iron Throne, even though the Mad King's son and daughter Viserys and Daenerys had escaped to the Free Cities to live in exile. Due to the death of Princess Elia, Dorne and House Martell withdrew from active involvement in the affairs of the rest of Westeros afterwards.
- The Sack of King's Landing at A Wiki of Ice and Fire (spoilers from the books)