On 15 June 1820, Valdivia was sworn into the new nation, after Thomas Cochrane led a successful attempt to capture Valdivia from the royalists. Later, on 22 January 1826, the pledge of independence would be made in San Carlos, Chiloé, after the Spanish signed the Treaty of Tantauco, which gave the Chiloé Archipelago to Chile.