First Intermedios campaign

The First Intermedios campaign (Primera campaña de Intermedios), also known as the 1822 campaign of the Intermedios ports (Campaña de los puertos intermedios de 1822), was a military expedition led by General Rudecindo Alvarado on behalf of the Peruvian Congress against the royalist forces stationed in the southern mountains of Peru.

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).

Background
José de San Martín, while he was in Peru as its Protector, dedicated himself to the organization of his army and to sketching his campaign plan, which was called "Campaign Plan for the Intermediate Ports." This plan consisted of attacking the royalists by three fronts:
 * An expeditionary army embarked in Callao should attack the Spanish through the intermediate ports of the South, that is, those located on the coast between Arequipa and Tarapacá.
 * Another army leaving Lima would attack the royalist forces in the central region, to prevent them from joining those in the south.
 * An Argentine army would attack the Spanish in Upper Peru (present-day Bolivia), with the same objective.

To carry out the plan, the assistance of Simón Bolívar was necessary, which San Martín was unable to obtain in the proportion needed. After San Martín's withdrawal from Peru, his plan would be put into practice by the Peruvian government on two occasions, although without success.

The First Constituent Congress of Peru, which after the departure of San Martín assumed all powers, resolved to form a Supreme Junta of Peru 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 and Manuel Salazar y Baquíjano, the latter a nobleman from Lima who still signed his title of Count of Vista Florida. The Board took office on September 21, 1822.

The main problem that the Junta had to face was the war against the Spanish. Viceroy José de la Serna had more than 20,000 soldiers who occupied the territory between Cerro de Pasco (central Peru) and Upper Peru (southern Peru). These forces were distributed as follows:
 * General José de Canterac was between Jauja and Huancayo, permanently threatening Lima.
 * General Juan Ramírez Orozco, in Arequipa.
 * Viceroy La Serna, in Cuzco.
 * General José Carratalá, in Puno.
 * General Pedro Antonio Olañeta, in Potosí.

On the coastal side, small royalist detachments were on an observation mission.

The Junta decided to put into practice the campaign plan drawn up by San Martín. For this purpose, the following was established:
 * Approaches were made to the government of Buenos Aires to attack the royalists in Upper Peru (which did not work due to the internal difficulties that said government faced).
 * General Juan Antonio Álvarez de Arenales was commissioned to prepare the patriot army that was to attack Canterac in the center (however, he was not given the necessary means to enter into operations in the planned period).
 * The expedition that would attack through the so-called "intermediate ports" was placed under the command of general Rudecindo Alvarado (brother of one of the members of the Government Junta), which was adequately equipped and was ready at the scheduled time to go into action. although the preparations mentioned above were not.
 * To finance the organization of the military forces, internal loans were arranged, especially with large merchants.

Organisation
The expedition that would open the campaign in the intermediate ports totaled approximately 4,490 men divided into three divisions: 1,700 were Argentines, 1,390 were Peruvians, and 1,200 Chileans. Each division kept its own flag and national insignia. But in real terms, the Peruvians covered two thirds of the total troops of the expeditionary army, since apart from the Peruvian Guard Legion itself, the rest of the Argentine and Chilean divisions covered their casualties or missing places with Peruvian elements, in a proportion that ranged from half to slightly more of its total strength. The Peruvian recruits came mostly from the Montoneras or guerrilla groups from the central region of Peru, which had an active and decisive role in the war.

These troops, under the name of the Southern Liberation Army (Ejército Libertador del Sur), embarked in Callao in the first days of October 1822. A force of 4,000 men called the Army of the Center (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. The Colombian division under the command of Juan Paz del Castillo had to be added to it, which had been sent by Bolívar in response to the request for help made by the Peruvian government. But Paz del Castillo refused to take action, citing the lack of equipment for his troops; although he did not wish to act as Arenales' subordinate either. In reality, this Colombian officer was following the express orders of Bolívar, who wanted to keep the division sent from Colombia intact. This defection on the patriot side prevented Arenales from initiating his actions in time, which finally had to be suspended.

Campaign
Alvarado began the campaign, but did not put dynamism into his actions, giving the royalists time to adopt a good defensive plan. 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. threatened by patriots. When Alvarado left Arica and advanced towards Tacna at the end of December, he detected the presence of royalist forces that had advanced rapidly from Upper Peru under the command of Gerónimo Valdés. These royalist forces only numbered a thousand troops, being therefore inferior in number to the patriots, but Valdés had the ability to move quickly towards Moquegua, entrenching himself in the area of Torata. There he resisted the patriot attack for several hours waiting for the arrival of the cavalry under the command of Canterac; Finally meeting both Spanish leaders, they defeated the patriots after breaking the tenacious resistance of the Peruvian Legion, which, together with the 4th Chilean Battalion (made up mainly of Indians and mestizos from Peru) had to face the greatest weight of the battle. This action is known as the Battle of Torata (January 19, 1823).

Encouraged by his victory, Valdés pursued Alvarado's troops, catching up with them and defeating them again in the Battle of Moquegua (January 21, 1823). 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.

The first Intermedios campaign therefore ended in total failure. The patriots only had some satisfaction with the partial victories of Guillermo Miller, who, with a small unit of 120 cavalry soldiers, landed in Quilca and operated between the towns of Camaná, Caravelí and Chala (current department of Arequipa) harassing the royalist troops located there, but aware of the patriot defeats of Torata and Moquegua, Miller reembarked in Quilca back to Callao.

Aftermath
This military failure ostensibly discredited the Government Junta, thus provoking the first coup d'état in Peruvian republican history: The Balconcillo mutiny. 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.

Bolívar was always concerned about the weak political and military position that the Lima government had. For him it was very easy for all of Peru to be reconquered by the royalists, which he considered fatal for the independence of Colombia. The monarchists had more than 20,000 men, without taking into account that Peruvian, Chilean and River Plate prisoners could be forcibly recruited. To recover the Peruvian territory, at least 12,000 men would be needed and they did not have the necessary resources to mobilize them, so it was better to prevent the Lima government from falling. For this, he would send a first body of reinforcements under the command of the Venezuelan general Juan Manuel Valdés 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. Once he arrived in Lima, Valdés had to send the fleet that had transported him back to Guayaquil so that the Liberator himself could lead another division of 2 to 3,000 Colombian soldiers. This new reinforcement unit would disembark in Trujillo and continue its march by land to the Peruvian capital. With Colombian reinforcements and Peruvian soldiers and recruits, Bolívar hoped to gather 12,000 combatants, more than half Colombian, while Canterac, by the time he could threaten Lima, would have 14 to 16,000.

The new Peruvian ruler organized a second campaign, which also failed, leaving the field open for Bolívar's intervention in Peru, just as the Liberator himself had planned. In mid-1823 Bolívar's power was assured in Peru by the 6,000 Colombians he had in the country, although only 5,500 survived the trip; His influence was such that he delayed the planned offensive on the Sierra and Upper Peru until he gathered 18,000-20,000, a third newly arrived Colombians, the same amount Peruvians that he recruited as soon as he arrived, the same amount from the Peruvian army and 2,500 to 3,000 Chileans that the Santiago government had promised.