Nieto was born in Ilo – Moquegua in 1803, to a Spanish-Peruvian noble family bearing the title of "Counts of Alastaya", who were also of local noble blood directly descended from the Inca Huayna Capac by marriage of his daughter Catalina Sisa Occllo to the Conquistador Pedro Ladron de Guevara, who is a direct ascendant of the family.
As an aristocratic youth, he quickly became disenchanted with Spanish rule and took the cause for Peruvian independence at the age of 18.
Being one of the few nobles at the time that participated directly in the wars of independence, he is a unique member of the "forefathers of the nation" pantheon in Perú.
He is also credited with participating and being victorious in the last recorded "personal combat" in the Battle of Tarqui, with the Venezuelan commandant José María Camacaro [es], assuming the challenge of deciding the fate of a battle in a single one-on-one combat.
In his final years, he led, with Ramón Castilla by his side, the overthrow of the "Supreme Dictator" Manuel Ignacio de Vivanco, assuming the presidency of Peru after being elected by the provisional Government Junta (provisional congress) charged with the re-establishment of constitutional order.