He studied in the College of San Carlos in Lima. When José de San Martín arrived in Peru in 1820, Salaverry left college despite the opposition of his father, and made his way to Huaura Province, where he volunteered to join the general and his forces. San Martin enlisted Salaverry as a cadet of the battalion of Numancia, in which he took part in the campaign against the Spaniards, he led the Peruvian Calvary at the battles of Junin and Ayacucho, obtaining the Independence of Peru and destroying the Spanish Army. After the establishment of the republic of Peru, Salaverry rose rapidly in the army. At the age of twenty-eight, Salaverry had obtained the rank of general and General Inspector of the Peruvian Army.
When the garrison of Callao revolted in January 1835, against then President Luis Orbegoso, and pronounced in favor of La Fuente, Salaverry defeated the insurgents. Orbegoso appointed him governor of the fortress. But on February 23, Salaverry rose in arms against the government. After Orbegoso abandoned Lima, Salaverry occupied the capital and proclaimed himself "Supreme Chief of the Republic". In a few months he had possession of the south, and Orbegoso retreated with a small force to the northern provinces.
He sought the intervention of Andrés Santa Cruz, leader of Bolivia, with whom Orbegoso concluded a treaty giving Santa Cruz a third of Peru. Soon after, the Bolivian army invaded Peru, and Salaverry retreated to the city of Arequipa. Salaverry obtained victories at the battle of Uchumayo, the 4th of February but on the 7th of February 1836, his forces were totally routed in Socabaya, a district of the city.
After wandering for several days in his way to join the Peruvian Navy stationed at the coast at Islay in Arequipa, Salaverry trusted the English General Miller who was persecuting him (English General fighting for Bolivia, Salaverry will not give the British access to peruvian ports), who delivered him to Santa Cruz. Contrary to the customs of war against enemies who surrender, Santa Cruz ordered the execution of Salaverry and his General Staff, they assaulted him at The Plaza Major of Arequipa being assassinated, he survived since the Bolivian soldiers were very respectful of this brave General who refuse to covered his eyes and who was severely injured with a bloody leg, the unjust Santa Cruz ordered to shut him again against the rules of civility, Salaverry was only thirty years old. This led to popular resistance and ultimately defeat of the Peru–Bolivian Confederation led by Santa Cruz, who escape to Chile and then to France. Salaverry's field jacket was given to his crying widow full of bullet wholes, which is shown at the Peruvian Museum of Gold at Monterrico.