Gibraltar was captured in 1704 by a force led by Admiral Sir George Rooke representing the Grand Alliance on behalf of the Archduke Charles, pretender to the Spanish Throne. After the battle, almost all of the inhabitants decided to leave. Spanish attempts to regain the territory in the Twelfth Siege of Gibraltar failed, and it was eventually ceded to the Kingdom of Great Britain by Spain in the 1713 Treaty of Utrecht as part of the settlement of the War of the Spanish Succession. In that treaty, Spain ceded to Great Britain "the full and entire propriety of the town and castle of Gibraltar, together with the port, fortifications, and forts thereunto belonging ... for ever, without any exception or impediment whatsoever."