The expedition had been planned by José de San Martín, but in his absence the execution failed, because the patriotic officers did not put the dynamism that the war actions required and also due to the quick reaction of the royalist leaders under the orders of viceroy José de la Serna, who, through forced marches through the Andes, managed to block the path to the United Liberating Army and triumphed in two consecutive battles: Torata and Moquegua (January 19 and 21, 1823).
The First Constituent Congress of Peru, which after the departure of San Martín assumed all powers, resolved to form a Supreme Government Junta [es] with members from its ranks, so that, in its name, it would exercise the functions of the Executive Branch.
Thus the Junta was formed, chaired by General José de La Mar and made up of Felipe Antonio Alvarado [es] and Manuel Salazar y Baquíjano, the latter a nobleman from Lima who still signed his title of Count of Vista Florida.
A force of 4,000 men called the Army of the Center (Spanish: Ejército del Centro) remained in Lima under the command of Argentine general Juan Antonio Álvarez de Arenales, in charge of attacking the royalists through Jauja.
Upon arriving in Iquique he had a detachment disembark to begin action on Upper Peru, although without giving precise instructions to the patriotic guerrillas fighting in that area.
Then he headed to Arica, where he stayed for three weeks, giving enough time for Viceroy La Serna, informed by his espionage service, to order the royalist generals José de Canterac and Gerónimo Valdés to go with their forces to the area.
The patriot troops, reduced to a quarter of their original number after suffering deaths, injuries, and desertions, had to hastily reembark in Ilo, returning nearly 1,000 survivors to Callao.
On February 26, 1823, the army generals, a group that had acquired a great amount of power, forced Congress to dissolve the Government Junta and appoint Colonel José de la Riva-Agüero as the first president of Peru.
For this, he would send a first body of reinforcements under the command of the Venezuelan general Juan Manuel Valdés [es] of 3,000 men to help the 4,000 defenders who still remained in Lima and Callao, taking advantage of the fact that Canterac and his army were far away, in Arequipa, they were due to arrive in April.