In April 1804, at the death of Viceroy Joaquín del Pino, he was named as his replacement as Viceroy of the Río de la Plata.
At that time, Great Britain and Spain were at war, creating the risk of an attack on Buenos Aires.