Robert I had a successful reign, inheriting a contested throne in a country partly occupied by the English, and leaving a securely governed kingdom to his son, David II. He was fortunate in that he was matched by an ineffectual English king, Edward II, over whom he won an important victory at Bannockburn in 1314. In 1322 Edward attempted a fresh invasion of Scotland, but Bruce outmanoeuvred him and then invaded England as far south as Yorkshire, nearly capturing Edward himself. In the Treaty of Edinburgh (1328), Edward III recognized Bruce’s title and Scotland’s independence from England, although this was only a temporary lull in Anglo-Scottish hostilities.