# Peruvian Republic (1838–1839)

The Peruvian Republic was a state that seceded from the Peru–Bolivian Confederation in 1838 under the leadership of General Luis Orbegoso.
Its territory comprised the totality of North Peru, which by a majority of votes proclaimed itself independent of the Peru-Bolivian Confederation. This was not accepted by the Confederation, however, and both countries went to war during the War of the Confederation. After Orbegoso and Santa Cruz reached an agreement, the country ceased to exist as a sovereign state on October 20, 1838 and instead became an autonomous republic within the confederation until its defeat by Agustín Gamarra and his United Restoration Army in 1839.

## History
### Declaration of independence

The territory that conformed the Confederate subdivision of North Peru was proclaimed independent of the Peru-Bolivian Confederation by Luis José de Orbegoso on July 30, 1838, until the territory was conquered by the United Restoration Army on August 21, 1838.
Orbegoso led a military campaign against Andrés de Santa Cruz together with the opponents of the confederation and were first allied with the Peruvian-Chilean alliance of the United Restoration Army. Before the acts of vandalism committed by the Chileans on north-Peruvian soil, however, and the little interest apparently shown by the Chilean generals, the Northern Peruvian Republic was led to declare war on both the confederation and the Peruvian-Chilean alliance.

### Battle of Portada de Guías

The restorative forces continued their advance towards Lima and encountered the Peruvian forces commanded by Orbegoso, Nieto and Vidal on the outskirts of Lima. The numerical difference was overwhelming: some 4,800 restaurateurs' compared to about 1,300 Peruvian orbegosistas. Despite this, a battle took place nevertheless, today known as the Battle of Portada de Guías, in which the restaurateurs won on August 21, 1838 and occupied Lima until the Confederates occupied it again. Gamarra, who had a more pro-Chilean stance, became president by way of open cabildo on August 25.
Orbegoso remained hidden in Lima for a few days, until he fled to Callao in unsuccessful disguise, being recognized. After being shot, he hid on the seashore remaining barely alive until the next day, where drenched and cold, he found refuge in the port within the Real Felipe Fortress. The port would see itself at the center of an ensuing siege between the restorationists and the confederates.

## Reunification with the Confederation

Orbegoso took refuge in the Real Felipe fortress. From there he denounced the Chilean army as invaders and declared that he intended to wage war on it with the same determination as against the army of Santa Cruz; and that he only wished to favor the meeting of a congress that would freely decide the fate of the country. However, he refused to deal with Gamarra, when he offered to formalize a commitment to beat Santa Cruz together with the restorationists.
In the end, Santa Cruz convinced Orbegoso to support him, promising that he would convene a Congress after expelling the invaders. Orbegoso believed him and announced on October 20, 1838 his new alliance with Santa Cruz. Thus, Santa Cruz managed to maintain the rebel state on his side as an autonomous republic by turning it against the restorer allies, causing the imminent invasion of the Confederate north and putting in its place the provisional Peruvian government of Agustín Gamarra, ignoring the regime of Orbegoso. A year later, the Confederates launched a reconquest campaign in the north, causing the restorers to flee and re-annexing the northern Peruvian territory. In the meantime, Gamarra and the restorationists would be the ones to defeat the Confederation in the Battle of Yungay of 1839.