{ { Infobox military conflict|
| conflict = Spanish-Algerian war (1775-1785) | place = Algeria and –Algerianwar–the Mediterranean Sea | partof = the Spanish-Barbary wars | result = Algerian victory <small> Peace treaty signed Spain pays 1,000,000 pesos as war reparations | date = 1775–1785 | combatant1 = Kingdom of Spain Kingdom of Naples Kingdom of Sicily Hospitaller Malta Kingdom of Portugal Duchy of Tuscany | combatant2 = Regency of Algiers | commander1 = Charles III Emmanuel Marie John Acton | commander2 = Muhammad V <small> Salah Bey Mohammed el Kebir Moustapha Ouaznadji | image = | caption = A Spanish Xebec facing two Algerian brave ships. | strength1 = 1775:20,000 men 7 ships of the line 12 frigates 27 gunboats 5 hulks 9 feluccas 4 mortar boats 7 galleys 3 smaller warships230 transports1783:76 ships1784:9 ships of the line 11 frigates 14 xebecs 90 smaller warships | strength2 = Total:4,000 Janissaries15,000 camelry14,000 infantry2 demi-galleys2 xebecs6 gunboats1 felucca70 galliots, gunboats, and other minor ships | casualties1 = 5,000 dead2,000 wounded | casualties2 = 300 dead (1775)unknown total deaths65 galiots and gunboats destroyed |campaignbox = }}
The Spanish-Algerian war (1775–1785)' was a conflict between the Spanish Empire and the Deylik of Algiers.
An attempted peace treaty in 1766 resulted only in an exchange of captives. 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. Algerian privateering increased post-invasion, and Spain's attempts at peace through diplomacy and bribery were unsuccessful. Two separate bombardments of Algiers by Rear admiral Antonio Barceló in 1783 and 1784 inflicted limited damage and failed to compel Algerian surrender. The war concluded in 1785 with a treaty that required Spain to pay 1,000,000 Pesos in war reparations but failed to end hostilities or piracy.
Background
Spain and Algeria were in a de facto constant state of conflict, ever since the Spanish-Algerian War (1504–1512), albeit war was rarely declared. Spain was especially crippled by this since Algerine pirates had been constantly harassing the Spanish coast, Spain fought multiple wars with Algeria, but they were never able to end the local piracy once and for all. On top of that Spain held both Oran and Mers El Kébir, following their decisive victory in 1732. In 1766, some time after Baba Mohammed ben-Osman (also known as Muhammad V) was elected by the diwan of Algiers to be the Dey of Algiers, Spain attempted to sign a peace treaty with them, but that only ended in the exchange of captives in 1767, and 1768. 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.
The War
The Invasion of Algiers (1775) By June the task force that had been assembled was enormous, with seven ships of the line, twelve frigates, twenty-seven gunboats, five hulks, nine feluccas, four mortar boats, seven galleys and three smaller warships, along with two hundred and thirty transport ships. 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. On July 5, the combined Spanish and Tuscan force reached Algiers, and O'Reilly made the decision to land troops to capture the city. The Spanish troops landed in two waves, but became deeply uncomfortable by the sweltering summer heat. 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. Despite the strict instructions that O'Reilly gave to his troops, the pilots of the landing craft mistakenly chose the wrong landing area and the artillery guns being transported on the landing craft became stuck fast in the dunes of the beach after being landed, making them totally unusable for combat. Once ashore, the Spanish were met initially with light Algerian resistance, mainly because a feigned retreat by the forces advancing from Algiers. 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.