Following the Andal Invasion, the Kingdom of the Rock became ruled by House Lannister, who descended from the Andal invaders and, through the female bloodline, the mythic Lann the Clever who, according to legend, swindled Casterly Rock from the Casterlys. The Lannisters ruled as Kings of the Rock until Aegon the Conqueror invaded Westeros. King Loren Lannister joined forces with Mern Gardener, King of the Reach, to wage war against the invaders. However, their forces were obliterated in the Field of Fire. While Mern perished, King Loren submitted to Aegon and the Kingdom of the Rock became one of the constituent regions of the unified Seven Kingdoms.
One of the real-world inspirations behind the naming of the Lannister Kingdom of the Rock (and perhaps Casterly Rock) may have been the early Medieval Kingdom of Strathclyde, known in its own time as the Kingdom of Alt Clut, or the Kingdom of the Rock, referring to Dumbarton Rock, which was the political centre of the nation.