Spanish American wars of independence important change in strategy after three United Provinces campaigns had been defeated in Upper Peru. San Martín's army became the nucleus of the Army of the Andes, which received crucial political and material support in 1816 when Juan Martín de Pueyrredón became Supreme Director of the United Provinces. In January 1817, San Martín was finally ready to advance against the royalists in Chile. Ignoring an injunction from the congress of the Río de la Plata not to move against Chile, San Martín together with General Bernardo O'Higgins Riquelme, later Supreme Director of Chile, led the Army over the Andes in
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