José Bernardo de Tagle y Portocarrero, Marquis of Torre Tagle resided in Spain between 1813 and 1817. On his return to Peru, now being a brigadier, he was appointed inspector of the army, and also named Governor of Trujillo. On the arrival of José de San Martín in Peru, he was the first Peruvian officer to hoist the national flag in the north of Peru, and on 24 December 1820 proclaimed Trujillo independent. On 26 July 1822, he was appointed provisional president by San Martin when the latter went to meet Simón Bolivar in Guayaquil. After the departure of San Martin for Chile, on 20 September, Torre Tagle was elected
Army of the North and 9 artillery pieces could not deal with the 5,100 royalists and 23 artillery pieces and had to escape with about 1,000 casualties, while the royalists only counted 32 dead. Objectives were not met and the provinces were left surrounded by potential enemies. British and French could arrive by sea, Portuguese from the East and Spaniards from the North. Had they conquered Upper Perú, the biggest threat, the royalists, would have been ended. In January 1816, Lieutenant Colonel Gregorio Aráoz de Lamadrid was sent to the north, but on 31 January was defeated at Culpina. On 2 February he won