First siege of Callao

The first siege of Callao was a prolonged military blockade of the Real Felipe Fortress (as well as other fortresses) in Callao by the Liberating Expedition of Peru under the command of General José de San Martín in July 1821 which culminated in the capitulation of Marshal José de La Mar in September of the same year, with him switching sides from the Royalist side to the Patriot side.

Background
On July 12, 1821, after the withdrawal of Viceroy José de la Serna and his army to the mountains, the army under the command of San Martín occupied Lima and the next day the land siege of Callao began, which, together with the Third blockade of Callao previously carried out by the Chilean fleet under the command of Admiral Thomas Cochrane, came to complete the siege.

The viceroy had a garrison of 2,000 men composed of regular soldiers and urban militias under the command of the governor and head of the square to defend the port. Marshal José de La Mar received an ultimatum on July 13 from General San Martín, which he refused.

The siege
During the siege, shootings were frequent between the patriotic garrison, ships and outposts that harassed the defenders. On July 24, a parliamentarian received in the square the proclamations of independence of General San Martín, which unsuccessfully sought to win the royalist garrison to the patriot cause. Due to the unsuccessful result of this proposal, that same night the Cochrane's fleet attacked the port, setting fire to two smaller ships and taking three. The fighting continued and on August 4 the besiegers began to bomb the castles with obuses, repeating this operation every night until the 14th in order to keep the royalist soldiers fatigued and demoralized. That same day, General Juan Gregorio de las Heras led a daring ground attack on the plaza. The plan was for 150 horsemen and 1,000 infantrymen to race from their barracks in Bellavista and overrun the fortress gates before they could be lifted. The plan ended unsuccessfully. However, the patriot cavalry managed to kill or capture the soldiers who had not managed to enter the fortress. Because of this, the patriots had 27 casualties while the royalists 41, with Colonel Mariano Ricafort being wounded and taken prisoner.

Canterac's incursion into Lima
Meanwhile, from Cuzco, Viceroy La Serna had planned an incursion on the Lima valley, which, led by General José de Canterac, commanding 3,100 soldiers and 9 artillery pieces, left Jauja at the end of August. After crossing the Andean mountain range in a difficult journey and having to face the montoneros, the troops reached the outskirts of the capital on September 8, where they found the patriot army maintaining defensive positions. Although San Martín had a superior army based on the number of troops, he decided not to attack despite the insistence of General Las Heras, thus allowing Canterac to march until he entered Callao.

"They are lost. Callao is ours. They do not have provisions for fifteen days. The auxiliaries of the mountains are going to eat them. Within 8 days they will have to surrender or meet the end of our bayonets."

After holding a war junta in Callao, Canterac chose to return to the mountains. His men left the fortresses with enthusiasm and cheering the king because they believed that they were going to fight, however, as they turned north, crossed the Rímac river and saw themselves facing the painful prospect of crossing the mountain range again, demoralization spread in the royalist army, as desertions increased to alarming levels. Despite their success against San Martín's troops that had sent in pursuit under the command of General Guillermo Miller, upon returning to Jauja, the army was seriously reduced in number and supplies.

End of the siege
When Canterac left the castles, the Callao garrison was again isolated and with provisions for only four days. As the possibilities of the besieged receiving reinforcements or supplies of any kind became remote, San Martín offered La Mar an honorable surrender, assuring him that Canterac's army was moving away in a disastrous state and in frank dispersion. Faced with this situation, La Mar called a war junta where it was concluded that there was no alternative but surrender.

The conditions of capitulation allowed the royalist troops to withdraw in full dress, carrying their light weapons and with their flags unfurled, being saluted in the march by the artillery of the patriot army. After leaving their rifles on the flag, the regular soldiers were allowed to march to join the royalist army stationed in Arequipa and the militiamen to return to their homes. As reported by the Chilean Ministerial Gazette, the capitulated forces were 600 soldiers and 1000 militiamen.

The benevolent conditions of San Martín, although criticized by some historians, allowed the patriot cause to win over some individuals who until then were active in the royalist army, recognizing the same rank and employment in the patriot army, among them La Mar himself, who, after renouncing his degrees and decorations that he received for his services in Spain and Peru, faithfully served the cause of independence until the battle of Ayacucho and later became president of Peru.