He was replaced in 1809 by Baltasar Hidalgo de Cisneros, appointed as viceroy by the Junta of Seville, and retired from public activity.
He benefited from the third Pacte de Famille (1761), which allowed Frenchmen to take part in Spanish military campaigns with equal rights and requirements as the Spaniards.
In 1782, he distinguished himself particularly in the siege of Port Mahon: under fire, he moved to where two British ships had collided, which were laden with arms and ammunition.
The Barbary pirates associated with North Africa had long been attacking European shipping in the Mediterranean, and had taken numerous prisoners over the years.
[8] The Spanish court rewarded Liniers for this diplomatic success, promoting him to the rank of captain and entrusting him with the command of the Río de la Plata in 1788 to organize a flotilla of gunships.
Needing new markets, Britain invaded Buenos Aires and Montevideo, two Spanish colonies in South America (Spain was allied to France in the war).
[10] June 23, 1806, a British expeditionary force of 1,700 men landed on the left bank of the Río de la Plata and invaded Buenos Aires, which had been abandoned by the Viceroy.
Liniers drafted all the male population capable of bearing arms, including African slaves, into the defense of the city.
Whitelocke's defeat was complete, and Liniers demanded that all British forces be removed from the territories of Viceroyalty, including the Banda Oriental, in no more than 2 months, as well as an exchange of prisoners.
However, this victory of the Argentine people which was obtained without any military help from Spain led to a new political situation in which some will for independence started to emerge.
In this configuration Liniers, who appeared to be a fantastic leader during the emergency crisis, began to be criticized by the different parties including the conservative members of the Cabildo, led by Álzaga.
On the opposite side, criollo people who were asking for more independence, had some difficulty understanding the perfect sense of loyalty of a navy officer issued from old French nobility who intended to respect his oath to the king of Spain.
As an example, his relation with Ana Périchon "la pericona" was severely pointed out, forcing him to lock her at her home and later to deport her to colonial Brazil.
[15] They also promoted in the Río de la Plata the xenophobia that was taking place in Spain against the French, as an indirect means to attack Liniers and lower his prestige.
The arrival of Sassenay, an agent of Napoleon seeking recognition for Joseph Bonaparte as King of Spain, boosted rumors and controversy.
The criollo peoples promoted the Carlotist project, which tried to crown Charlotte of Spain, sister of Ferdinand, as Regent of the Spanish territories in the Americas, under a Constitutional monarchy.
Álzaga set off a mutiny to do the same in Buenos Aires, but the forces under the command of Cornelio Saavedra defeated it and kept Liniers in power.
At this time, Liniers's father-in-law, Martín de Sarratea, wrote a letter to ask him to stay away from the counterrevolution, which he refused in the name of honour and respect to his word.
The Junta decided that, among the many enemies that could threaten it, Córdoba was the most dangerous, so an army led by Ortiz de Ocampo was sent to fight against it.
The mere proximity of the troops from Buenos Aires caused the complete dispersion of the army gathered by Liniers.
The Junta feared the effect that the entry of Liniers into the city might have, so Juan José Castelli was sent, with orders to replace Ocampo and execute the prisoners.
However, after the counterrevolution and the new number of heroes of the Argentine War of Independence, most names of such streets were modified in 1822, during the government of Martín Rodríguez.
The remains were brought back to Spain and solemnly buried in the Panteón de Marinos Ilustres of the island of San Fernando, Cádiz.
At this time, Liniers's descendants received the hereditary title of "Conde de la Lealtad" (Count of Loyalty).