There were multiple reasons for the French to plan an attack on Rio de Janeiro. Firstly, the commander Duguay-Trouin had a personal reason: he was almost bankrupt. The second reason was political. The War of the Spanish Succession had not gone well for France. After the defeat in the Battle of Malplaquet, the enemy was on French soil and French morale was low. A military success was urgently needed. The third reason was a question of honour. The previous year another buccaneer, Jean-François Duclerc had attempted an attack on Rio, but this expedition had ended in disaster; Duclerc and 600 of his soldiers were captured and held in unacceptable conditions. The Portuguese refused to exchange these prisoners as was stipulated in a Franco-Portuguese treaty from 1707; furthermore, Duclerc was killed in prison under mysterious circumstances in May 1711. The French wanted to liberate these prisoners, and possibly conquer some Brazilian territory.
Preparations
In December 1710 Louis XIV approved Duguay-Trouin's plan and provided him with a fleet of 17 ships, carrying in total 738 cannons and 6,139 men. The French treasury could not finance the armament of the squadron and therefore Duguay-Trouin had to search private financiers in Saint Malo and on the Royal Court; he received significant support from the Count of Toulouse. Finally the ships could be prepared and to fool the British Navy, allied to the Portuguese, the ships were prepared in different harbours, left at different times, and reassembled at sea off La Rochelle on June 9, 1711. British intelligence, however, were aware of Duguay-Trouin's goal, and had dispatched a packet to warn the Portuguese, both in Portugal and at Rio. They also dispatched a fleet under John Leake to blockade Duguay-Trouin before he sailed from Brest; they arrived two days too late.
The battle
In spite of the British warning, the French appearance in Rio's harbour on 12 September was a surprise. The British news, when it arrived in August, had led Governor Francisco de Moraes de Castro to call out his militia and increase preparedness, and rumours of sails off Cabo Frio in early September had again raised the alert. However, on 11 September the governor ordered the militia to stand down, just as Duguay-Trouin was preparing his approach to the harbour. The commander of Le Lys, Courserac, led the squadron directly in the Bay of Rio, between the forts lining the harbour entry, and straight at seven Portuguese warships that were anchored there. The Portuguese fleet commander, admiral Gaspar da Costa, could do nothing but cut the cables in hopes of getting his ships moving. Three of battleships grounded and were destroyed by the Portuguese to prevent their capture; the fourth was taken by the French and burned. Fire from the forts, undermanned after the order to stand down, did some damage to the French fleet, inflicting 300 casualties before the ships passed out of range. After 3 days of bombardments, the French landed 3,700 men to attack the city. The governor of Rio, Castro-Morais, had fortified the city after French attacks in previous years, but very feebly commanded the defense, which buckled under the French bombardment. After a council on 21 September in which Moraes ordered the city's defenders to hold the line, militia began deserting that night, after which there began a general flight from the city that included the governor. Under the disorganised circumstances, the French prisoners from Duclerc's expedition broke out of prison.
Aftermath
Duguay-Trouin, who had been preparing to storm the city, was alerted to the flight of the defenders by the arrival of one of Duclerc's men. Over the next few days, the French gained control of all of the bay's strong points, but the city's gold supply eluded him. Warned that reinforcements from São Paulo under command of António de Albuquerque were on their way, he threatened Moraes with the destruction of the city's defences if a ransom was not paid, which Moraes agreed to do. When the French left the city, it was with loot of estimated at 4 million pounds, including a shipment of African slaves, which Duguay-Trouin later sold in Cayenne. Two ships sank after a storm near the Azores. "One with considerable treasure aboard". The fleet arrived back unmolested in Brest in February 1712. The expedition was a military success for the French, and a financial success for its investors. The French Navy had proven it was still capable to strike at large distances. This action would trouble Franco-Portuguese relations for many years to come.