In 1704, during the War of the Spanish Succession, a combined Anglo-Dutch fleet, representing the Grand Alliance, captured the town of Gibraltar on behalf of the Archduke Charles of Austria in his campaign to become King of Spain. Subsequently, most of the population left the town with many settling nearby. As the Alliance's campaign faltered, the 1713 Treaty of Utrecht was negotiated, which ceded control of Gibraltar to Britain to secure Britain's withdrawal from the war. Unsuccessful attempts by Spanish monarchs to regain Gibraltar were made with the siege of 1727 and again with the Great Siege of Gibraltar (1779 to 1783), during the American War of Independence.