With Rhaegar dead at the Trident, Tywin Lannister marched twelve thousand men to King's Landing and asked to be let inside as a loyal lord come to defend the city. Aerys II, who had never trusted Tywin and had every reason not to start, was persuaded against his own instincts to open the gates. It was the last mistake of his reign.
Once inside, the Lannister host did not defend the city; it sacked it. Ser Gregor Clegane and Ser Amory Lorch, on orders the chronicle attributes to Tywin himself, found Princess Elia Martell and her children and murdered them in the Red Keep — the young princess killed hiding beneath her father's bed, the infant prince's body wrapped in a Lannister cloak and presented afterward as a gift. Through the streets below, Lannister soldiers did to the smallfolk what soldiers with no one left to answer to generally do.
Aerys II, hearing his city was lost, ordered his pyromancers to burn it around him rather than surrender it — caches of wildfire had been hidden beneath the streets for exactly this purpose. His own Kingsguard, Ser Jaime Lannister, killed him upon the Iron Throne before the order could be carried out, and so earned a name — Kingslayer — that outlived every other thing he ever did. Robert Baratheon arrived to a city already broken, and found the throne he had fought for waiting, its steel still warm.