The Edwardian castles and town walls in Gwynedd were built as a consequence of the wars fought for the control of Wales in the late 13th century. The kings of England and the Welsh princes had vied for control of the region since the 1070s, with Norman and English nobles and settlers slowly expanding their territories over several centuries. In the 1260s, however, the Welsh leader Llywelyn ap Gruffudd exploited a civil war between Henry III and rebel barons in England to become the dominant power, and was formally recognised as the prince of Wales under the Treaty of Montgomery.