Invasion of Algiers (1775)

The invasion of Algiers was a massive and disastrous amphibious attempt in July 1775 by a combined Spanish and Tuscan force to capture the city of Algiers, the capital of The Deylik of Algeria. 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 defending Algerian forces were led by Baba Mohammed ben-Osman. The assault was ordered by the King of Spain, Charles III, who was attempting to demonstrate to the Barbary States the power of the revitalized Spanish military after the disastrous Spanish experience in the Seven Years' War. 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.

The Spanish forces departed Cartagena in 1775 and sailed towards Algiers. On the coast, near the city, O'Reilly ordered the Spanish forces to land on the shores and capture the city, while the Spanish and Tuscan warships would protect the landing craft as they landed on the shore. However, the landing was flawed from the start, as the area chosen by the Spanish for the landing was not the one the pilots of the landing craft sailed towards, with the new landing site being totally unsuitable for bringing ashore the heavy artillery meant to bombard the city walls of Algiers. Most of the guns became stuck in the wet sand resulting in their absence from the ensuing fight. Despite this, the Spanish forces assaulted Algerian forces, who proceeded to draw back to positions further inland. The Spanish chose to pursue, but walked into a carefully set trap and suffered massive casualties, losing a quarter of their total force compared with light casualties on the Algerian side. 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.

Background
The armed forces of Spain had recently undergone a massive revival project under the personal command of the King of Spain, Charles III. This came after the humiliating Spanish defeat in the Seven Years' War, where Charles had declared war on the Kingdom of Great Britain in support of his traditional Bourbon allies, the Kingdom of France, in 1762. 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. This made Charles realize that the Spanish military needed to undergo reforms in order to be effective in any future wars. Spain at the time held several exclaves on the coast of North Africa, although these were constantly under threat of Moroccan or Ottoman encroachment. Charles was determined to not lose any more territory after ceding Florida to the British, a similar rationale for the French conquest of Corsica.

After Spanish forces had successfully broken the Moroccan siege on the Spanish-held city of Melilla in 1774, the government of Charles III of Spain decided to send a naval expedition to the North African coast, as he was determined to demonstrate to Sultan Mohammed III that Spain would not waver in its resolve to hold onto its possessions. The Spanish objective was to occupy Algiers; a key and supposedly vulnerable port, and a beating heart of Ottoman Algeria. The expedition was commanded by Alexander O'Reilly, an Irish officer who at a young age had entered Spanish military service, being a member of the Irish military diaspora. O'Reilly had long had a distinguished career in service of Spain. As head of the royal household guard in 1765, he had personally protected Charles III from an attempt on his life. In the aftermath of the Seven Years' War, he personally received Havana when the British handed it back to the Spanish in the aftermath of the Treaty of Paris (1763). He had also crushed the Louisiana Rebellion of 1768 by French settlers after the territory had been transferred from France to Spain. 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.

The battle
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. 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 Spanish advanced forwards to engage the seemingly retreating Algerian forces, and moved further inland. However, the Algerians drew the Spanish into a specially chosen location where they could ambush and attack them from cover. By now the Spanish had realized the position they were in, at the same time the Algerians sprung their trap. However by the time the Spanish realized they were surrounded, it was too late for them. Unable to hold an effective line of resistance, the Spanish forces were routed, returning in chaos to their ships. 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. 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. The incessant fire of his great guns, loaded with grape-shot, not only stopped them, but obliged them to retire with great loss." 2,000 Spaniards were captured as many were cut off from the boats that would have allowed them to return to their ships. O'Reilly had to wait for a month to negotiate their return. He then wanted to retaliate by bombarding Algiers from the sea, but he learned that he had only enough provisions on board to last for an immediate return to Spain. O'Reilly and the Spanish fleet withdrew to Alicante with his reputation now in tatters.

Aftermath
Although in general Charles III's reforms of the Spanish military would go on to enhance his country's military standing and effectiveness in future wars, O'Reilly's poor preparations and ineffective leadership made a mockery of the Spanish army. There were several reasons for the Spanish defeat: while the Algerian forces had detailed intelligence on the Spanish, the Spanish had no information on Algerian strength or positions, the majority of the Spanish forces consisted of recently recruited soldiers with little training whereas the Algerians had many veteran warriors among them, and the Algerians confronted the Spanish with a united command, whereas O'Reilly and the commander of the Spanish ships had many disagreements and suffered from a lack of communication. The bitter relationship between O'Reilly and the various Spanish admirals resulted in an extraordinary lack of cohesive planning and organisation, which in turn left O'Reilly with inadequate provisions and armaments.

New developments changed the strategic situation when Charles appointed the Count of Floridablanca as his foreign minister in 1777. Supervising Spain's foreign affairs for fifteen years, Floridablanca became one of the most effective and respected of public servants in the Kingdom of Spain. Despite the failed invasion attempt, in 1780 Spain and Morocco signed a treaty of friendship at the Peace of Aranjuez. Mohammed III had recognized that his own interests in Ottoman Algeria would only be possible if he had Spanish support. In 1785, the sultan demonstrated the extent of his influence in Algiers by sponsoring a treaty between Spain and Ottoman Algeria after the Spanish attempted twice to bomb Algiers using their fleet, the first bombardment and the second bombardment were also failures. Nevertheless the tensions Spain had chronically encountered along the Barbary Coast were now reduced thanks to Floridablanca's skilful diplomacy, although the Barbary Slave Trade continued unabated, now that the Spanish would pose no threat to a centre of the trade. It was now left for other nations such as the United Kingdom, the Netherlands and the United States to deal with the Barbary pirates and ending the slavery there. The United States fought and won two wars against the Barbary states. In 1816, a combined Anglo-Dutch force bombarded Algiers in an attempt to put an end to the slave trade in Algiers, with the Royal Navy and Dutch Navy working in unison. The Barbary slave trade ended for good when France began the conquest of Algeria in 1830.