 Intermittent warfare continued until 1817.With Carrera in prison in Argentina, O'Higgins and anti-Carrera cohort José de San Martín, hero of the Argentine War of Independence, led an army that crossed the Andes into Chile and defeated the royalists.On 12 February 1818, Chile was proclaimed an independent republic.