The amphibious assault was led by Spanish general Alexander O'Reilly and Tuscan admiral Sir John Acton, commanding a total of 20,000 men along with 74 warships of various sizes and 230 transport ships carrying the troops for the invasion.
The assault was also meant to demonstrate that Spain would defend its North African exclaves against any Ottoman or Moroccan encroachment, and reduce the influence that the Barbary states held in the Mediterranean.
Forced to retreat back to their boats waiting offshore, the assault ended in a spectacular failure and the campaign proved to be a humiliating blow to the Spanish military reorganisation.
However, Havana and Manila, the capital of the Spanish colonial empire in the Americas and Asia, were both rapidly captured by the British and a disastrous invasion of Portugal was repulsed.
In command of the naval element of the expedition was Spanish admiral Pedro Gonzalez de Castejon, and together they planned and organised a task force by late spring to carry out the invasion.
Twenty thousand soldiers, sailors and marines completed the complement and it set course from the port of Cartagena for Algiers, reaching its destination by the beginning of July.
[2] On July 5, the combined Spanish and Tuscan force reached Algiers, and O'Reilly made the decision to land troops to capture the city.
Spanish admiral Antonio Barceló instructed his warships to protect the landing craft as they approached, but despite the bays shallow water he stuck to the coast as close as possible to maximize the effectiveness of his ships.
The latter had been massively augmented by warrior tribesmen from the interior, who sent forces to Algiers after having been alerted by intelligence sent by Berber merchants in Marseilles who had followed the course of Spanish military preparations during the spring of 1775.
[8] Pedro Caro Fontes, 2nd Marquis de La Romana, at the head of two regiments, was killed by two shots to the chest, minutes after landing.
The losses were huge; suffering more than 5,000 casualties, including five generals killed and fifteen wounded (with one of these being Bernado de Galvez), and abandoning to the Algerians no fewer than 15 artillery pieces and some 9000 other weapons.
[6] Henry Swinburne, a British travel writer wrote that the Spanish would have been "broken and slaughtered to a man... had not Mr. Acton, the Tuscan commander, cut his cables, and let his ships drive in to shore just as the enemy was coming on us full gallop.