Bernardo O'Higgins accepted the position instead, and became the leader of an independent Chile. He was granted dictatorial powers as Supreme Director on 16 February 1817. On 12 February 1818, Chile proclaimed itself an independent republic. Throughout the war with the royalists, O'Higgins had engaged in an ongoing feud with José Miguel Carrera. After their retreat in 1814, O'Higgins had fared much better than Carrera, who found little support forthcoming from San Martín, O'Higgins' political ally. Carrera was imprisoned to prevent his involvement in Chilean affairs; after his escape, he ended up taking the winning side in the Argentine Federalist war, helping
Army of the North of the Royalist forces in Upper Peru. On 12 May Orozco commanding a force of 4,000 men advanced to Jujuy, and on 28 May occupied the city, then on 31 May occupied Salta. On 2 June the royalist forces defeated the patriots at Chamical (southwest of the city of Salta). At the battle of Las Cañas lieutenant colonel Rojas was killed but the force of 400 royalists was defeated. On 8 June there was a new independentist victory at Cuesta de la Pedrera (southeast of Salta), dispersing 2,000 royalists who retreated to Jujuy. At the battle of Yala another royalist