In July 1482 an English army invaded Scotland during the Anglo-Scottish Wars. The town of Berwick-upon-Tweed and its castle were captured and the English army briefly occupied Edinburgh. These events followed the signing of the Treaty of Fotheringhay, 11 June 1482, in which Alexander Stewart, Duke of Albany, the brother of James III of Scotland declared himself King of Scotland and swore loyalty to Edward IV of England. The follow-up invasion of Scotland under the command of Edward's brother, Richard, Duke of Gloucester failed to install Albany on the throne, but Berwick has remained English ever since the castle surrendered on 24 August. The English army left Edinburgh with a promise for the repayment of the dowry paid for the marriage of Princess Cecily of England to the Scottish Prince.