Cardiff Castle (Castell Caerdydd) is a medieval castle and Victorian Gothic revival mansion located in the city centre of Cardiff, Wales. The original motte and bailey castle was built in the late 11th century by Norman invaders on top of a 3rd-century Roman fort. The castle was commissioned either by William the Conqueror or by Robert Fitzhamon, and formed the heart of the medieval town of Cardiff and the Marcher Lord territory of Glamorgan. In the 12th century the castle began to be rebuilt in stone, probably by Robert of Gloucester, with a shell keep and substantial defensive walls being erected. Further work was conducted by the 6th Earl of Gloucester in the second half of the 13th century. Cardiff Castle was repeatedly involved in the conflicts between the Anglo-Normans and the Welsh, being attacked several times in the 12th century, and stormed in 1404 during the revolt of Owain Glyndŵr.
After being held by the de Clare and Despenser families for several centuries, the castle was acquired by The 13th Earl of Warwick and Comte de Aumale in 1423. Lord Warwick conducted extensive work on the castle, founding the main range on the west side of the castle, dominated by a tall octagonal tower. Following the Wars of the Roses, the status of the castle as a Marcher territory was revoked and its military significance began to decline. The Herbert family took over the property in 1550, remodelling parts of the main range and carrying out construction work in the outer bailey, then occupied by Cardiff's Shire Hall and other buildings. During the English Civil War Cardiff Castle was initially taken by a Parliamentary force, but was regained by Royalist supporters in 1645. When fighting broke out again in 1648, a Royalist army attacked Cardiff in a bid to regain the castle, leading to the Battle of St Fagans just outside the city. Cardiff Castle escaped potential destruction by Parliament after the war and was instead garrisoned, probably to protect against a possible Scottish invasion.