Argentina and Chile were close allies during the wars of independence from the Spanish Empire. Chile, like most of the revolting colonies, was defeated at a point by Spanish armies, while Argentina remained independent throughout its war of independence. After the Chilean defeat in the Disaster of Rancagua, the remnants of the Chilean Army led by Bernardo O'Higgins took refuge in Mendoza. Argentine General José de San Martín, by that time governor of the region, included the Chilean exiles in the Army of the Andes, and in 1817 led the crossing of the Andes, defeated the Spaniards, and confirmed the Chilean Independence. While he was in Santiago, Chile a cabildo abierto (open town hall meeting) offered San Martín the governorship of Chile, which he declined, in order to continue the liberating campaign in Peru.