During the Dark Ages in Wales the country's geography made it all but impossible for a single united kingdom to emerge. In practice there were four kingdoms that occasionally worked together, but mostly fought each other – Powys in the borders; Morganwg in the south-east; Deheubarth in the south-west and Gwynedd in the north-west.
The first castles came to Wales with the Norman Conquest, just as they had in England. William the Conqueror didn't plan to invade Wales, indeed he never marched an army into the country, however with the strength of the Welsh princes at that time he viewed Wales as a potential danger.
He created three Welsh 'Marcher' earldoms along the English-Welsh border and gave them to three of his most trusted men – William FitzOsbern of Hereford; Roger de Montgomery of Shrewsbury and Hugh d'Avranches of Chester. They enjoyed numerous special privileges and almost total freedom to rule over their lands including the ability to build castles without express royal approval.
The first castle in Wales was constructed by William FitzOsbern at Chepstow in 1067. Unusually, it was constructed in stone from the beginning and was among the first stone castles in Britain. The Marcher Lords pressed forward building castles as they went and Wales became a land for private conquest for Norman adventurers.
By the time of Henry I the Norman lords had control of most of the coastline of South Wales. However they had little control of central and northern Wales. The native Welsh were also becoming more familiar with Norman tactics and weaponry and were able to put up better and more coordinated resistance.
During the 12th Century in England stone castles were becoming common. In Wales though castles were at the centre of a bloody struggle for power and often changed hands. As a result there were relatively few stone castles built at this time because they were expensive and required some security to construct.
This changed during the early 13th Century under William Marshall, Earl of Pembroke. Many of his knights had been on the Third Crusade and they brought new ideas and military innovations in castle building back with them. Pembroke and Chepstow were remodelled and his sons raised towers and curtains at Cilgerran and Usk. Other examples quickly followed in places like Caldicot, Skenfrith, Grosmont and Tretower.
During the early 12th Century the Welsh princes consolidated their power under Llywelyn the Great and later under Llywelyn 'the Last'. They tended to destroy English castles rather than garrison them, but they did build castles of their own. Llywelyn the Great followed English innovations closely when he raised his fortresses at Dolwyddelan, Dolbadarn and Castell-y-Bere.
Llywelyn the Last made a dangerous mistake when Edward I of England came to the throne. Despite Edward's insistence, Llywelyn didn't pay homage to the new king. Edward invaded on no less than three occasions and built castles as he went.
He spent huge sums of money raising a ring of castles around Wales and Gwynedd in particular, including superb royal castles at Beaumaris, Flint, Conwy, Rhuddlan, Aberystwyth and Caernarfon. These new castles were designed to be secure royal palaces capable of housing a large retinue as well as being strong fortresses.
Edward II's reign saw many of his father's castles being finished, though the construction of some of the baronial castles continued into the 14th Century. Others, like Chirk, were left incomplete as conditions became more favourable and their necessity declined.
The threat of French invasion in the late 14th Century saw Edward III build some new castles, but mostly repair and fortify existing castles, particularly along the coastline.
The last great uprising in Wales began in 1400 when Owain Glyndwr organised an uprising against Henry IV. Many of the existing castles were too strong to be taken by his forces, but he did succeed in capturing Carmarthen Castle, Harlech and Aberystwyth.
Owain was defeated eventually and the royal castles were properly garrisoned and maintained for some time afterwards.
In 1536 the Act of Union abolished the extensive rights of the Marcher lords and brought order and comparative prosperity to the land. By this time castles had lost much of their use as a defensive structure and most of the upgrades were domestic in nature.
The Civil War was a story of the gradual capture of Welsh castles by Parliamentary forces. Many of the Welsh castles remained loyal to King Charles I and the Parliamentarians didn't have the guns necessary to break down the walls. Though many of them escaped being damaged in war Cromwell's policy of slighting castles took its own toll.
In the 19th Century the romantic ruins and stunning Welsh landscape made the Welsh castles attractive to both tourists and artists alike. Local pride had stopped people stealing the stone for other projects in many places. A few new neo-Norman castles were built while others were rebuilt or made-over in a romanticised Victorian Gothic style.
Wales still has a range of spectacular medieval castles to visit, many of which are open to the public or have Historic Monument status.