Spain officially declared war in 1775, launching an ill-fated invasion led by Alejandro O'Reilly that was repelled with significant losses, despite support from Tuscan forces.
Two separate bombardments of Algiers by Rear admiral Antonio Barceló in 1783 and 1784 inflicted limited damage and failed to compel Algerian surrender.
[7] In 1775, after raids didn't stop, Spain de jure declared war, and in May, sent Alejandro O'Reilly to lead an expedition against Algiers.
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.
On the way, they joined forces with the small fleet of the Grand Duchy of Tuscany led by Tuscan admiral Sir John Acton.
[1] 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.
The losses were huge; suffering nearly 3,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.
[4] 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.
Don Juan de Bouligny was sent to Constantinople in 1782 and managed to obtain a friendship and commercial agreement with Sultan Abdul Hamid I.
[12] King Charles III, feeling that the national pride of Spain had been offended by the Algerines, resolved to punish them by bombarding their town.
Though he was by far the most capable naval officer of Spain and one of the few who had risen through the ranks by merit, Barceló's designation was coldly received both by the Spanish court and military.
[3] On 29 July the Spanish fleet came in sight of the town and two days later Barceló formed his line of battle and made the necessary dispositions for the attack.