Cardiff Castle (Welsh: Castell Caerdydd) is a medieval castle and Victorian Gothic revival mansion located in the Castle Quarter 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 by either 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 Richard de Clare 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 during in 1404 during the Owain Glyndŵr rebellion.
After being held by the de Clare and Despenser families for several centuries, Richard de Beauchamp acquired the castle in 1423. Richard conducted extensive work at 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 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 to protect against a possible Scottish invasion.
In the mid-18th century Cardiff Castle passed into the hands of the Marquises of Bute. John Stuart, the first Marquis, employed Capability Brown and Henry Holland to renovate the main range, turning it into a Georgian mansion, and to landscape the castle grounds, demolishing many of the older medieval buildings and walls. During the first half of the 19th century the family became extremely wealthy as a result of the growth of the coal industry in Glamorgan. The third Marquis, John Crichton-Stuart, used this to back an extensive programme of renovations under William Burges. Burgess remodelled the castle in a medieval Gothic revival style, lavishing money and attention on the main range. The resulting interior designs are considered by historian Megan Aldrich to be amongst "the most magnificent that the gothic revival ever achieved". The grounds were re-landscaped and, following the discovery of the old Roman remains, reconstruction Roman walls and a gatehouse were incorporated into the castle design. Extensive landscaped parks were built around the outside of the castle.
In the early 20th century the fourth Marquis, John, inherited the castle and construction work continued into the 1920s. The Bute lands and commercial interests around Cardiff were sold off or nationalised during the period until, by the time of the Second World War, almost only the castle remained. During the war extensive air raid shelters were built in the castle walls, able to hold up to 1,800 people. When the Marquis died in 1947, the castle was given to the city of Cardiff. Today the castle is run as a tourist attraction, with the grounds housing a regimental museum and interpretation centre. The castle has also served as a venue for numerous events, including musical performances, Mardi Gras festivals and baseball games.