His father was the soldier and politician Juan Bautista de Lavalle y Zugasti, son of the 1st Count of Premio Real and he himself Count of San Antonio de Vista Alegre, who decided to remain in Peru after the War of Independence and was later Interim President of the Republic.
When the War of Independence broke out, part of his maternal family remained loyal to Spain and decided to move to Madrid.
He was also a cousin of the Spanish diplomat José Antonio de Lavalle y Motezuma, 4th Count of Premio Real, on his father's side.
At 22 years old, he published his exegetical commentaries to the Peruvian Constitution in El Heraldo de Lima led by Toribio Pacheco.
Apuntes sobre su vida y sus obras, a historical biography on the life of Pablo de Olavide.
Lavalle founded and published La Revista de Lima among with Pacheco and Ricardo Palma in 1860.
This literary magazine was created as a continuation of El Mercurio Peruano and was considered one of the most important of its kind during the three years of its publication.
In 1866, after the proclamation of Mariano I. Prado as Dictator and the dissolution of the Congress, he and his family moved to Europe living in France, Spain, England, Belgium, The Netherlands, Switzerland and Germany.
Released in 1883, he returned to Peru and was appointed by an interim government Minister of Foreign Affairs, signing in this capacity the Treaty of Ancón.