Wales as a country evolved over a period of time after the Saxons completed their conquest of the rest of Britain. To recap, the Romans left Britain in 410 AD, leaving the ‘Britons’ to fend for themselves against succeeding waves of raiders from the north and east. These includes the Angles, Saxons, and Jutes. Historians are not in agreement as to exactly how this worked, but the Britons as a culture and society were driven further and further west until they reached their last bastions in Wales.
Regardless of the actual timeline, by 800 AD, the Saxons were well established right up to the border of what is now Wales. Offa’s Dyke, an earthen wall built in the 8th century, delineated the border for much of the early Middle Ages.
“Offa was King of Mercia from 757 to 796 AD. His kingdom covered the area between the Trent/Mersey rivers in the North to the Thames Valley i
n the South, and from the Welsh border in the West to the Fens in the East. At the height of his power, however, he also controlled Kent, East Anglia and Lindsay (Lincoln), and had alliances with Northumbria and Wessex, sealed by the marriage of two of his daughters to their Kings, Aethelred and Beorhtic respectively. He was, therefore, effectively an early King of England.” http://www.offasdyke.demon.co.uk/dyke.htm
By the time of the two Llywelyn’s in the 13th century, the kingdoms of Wales were more consolidated. Llywelyn the Great, who ruled in the early half of the century, controlled all but a few regions of Wales, which the Marcher (Norman) lords still controlled.
His grandson, Llywelyn ap Gruffydd, gained and lost (and then gained again) much of this territory over the course of his reign from roughly 1246 to his death in 1282.