Initially there was little that could be done, due to the strength of the Barbary powers, but gradually a pattern emerged of individual European navies bombarding the pirate ports until an agreement was reached to exclude that particular country's ships from piracy. Such agreements tended to be temporary, and especially in the Mediterranean slave raids were a constant fear until the power of the Barbary pirates was eventually destroyed.
Various peace treaties made by England with the Barbary states, but most are quickly broken.
1661 and 1663
The Dutch Navy under Michiel de Ruyter forces an agreement with the Barbary states, but it doesn't last long.
The Dutch Navy launches a punitive expedition against the Barbary States.
The Dutch fleet at Tripoli, 1670
An English squadron under Edward Spagge destroys 10 pirate ships at Bougie Bay near Algiers, the strongest of the Barbary states. Spragge follows this up with a bombardment of the city, sinking several ships, and Algiers signs a peace treaty with England
A Royal Navy squadron under Sir John Narborough forces a treaty with Tunis and, after bombardment of the city, with Tripoli.
Sale signs a peace treaty with England
Algiers,. not unexpectedly, breaks their peace treaty with England, but a series of defeats at the hands of an English squadron under Arthur Herbert forces them to make peace in 1682, which actually lasts until 1816.
French Navy bombards Algiers
The French attack on Algiers, 1682
French Navy bombards Algiers again
French Navy bombards Tripoli and forces a peace treaty
French Navy bombards Algiers yet again and finally a peace treaty is signed.
1783 and 84
The navy of Spain, long one of the worst sufferers of Barbary piracy, bombards Algiers, with 4x ships of the line, as well as two each from Portugal and Naples and one from Malta, in a rare example of national cooperation. Over 20,000 cannon balls are fired, much of the city and it´s fortifications are destroyed and most of the Algerian fleet sunk. The Spanish threaten to return every year until a peace treaty is signed and the Algerians give in, as do the Tunisians when threatened with similar treatment.
The Venetian Navy blockades Tunis and several neighbouring towns, but isn't strong enough to force an agreement.
1784 - 1802
Algiers, Morocco and Tripoli demand huge amounts from the USA to prevent piracy of American ships.
The USS Enterprise, of the newly formed US Navy, defeated the Tripoli, from, actually, Tripoli.
Tripoli forces capture the USS Philadelphia and take her crew hostage.
American forces under Lt. Decatur board and destroy the Philadelphia. US forces blockade Tripoli and try to capture the city, unsuccessfully. US and allied forces conquer the nearby city of Derma in 1805. Tripoli signs a peace treaty, though gains a large ransom for the captured American crews.
Following renewed piracy against US ships, two squadrons of the US navy are sent to the Mediterranean. The Algerian flagship is captured and under threat of bombardment Algiers returns all prisoners and signs a treaty.
The End of the Barbary States
The Napoleonic Wars ended with Europe united as never before, and England having the most experienced and powerful navy the world had yet seen. England was also acquiring a new mission, the abolition of the slave trade. These factors should have encouraged the Barbary states to "keep their heads down" - it didn´t.
In 1815 a squadron from Tunis sacked Palma on the island of Sardinia and carried off 158 inhabitants to slavery. This caused outrage in Europe, and a number of accusations that Britain´s new found enthusiasm for abolition was more about reducing the competitiveness of their rivals in the Americas than slavery as such. In response Lord Exmouth was sent to the Mediterranean with a Royal Naval squadron to wring concessions from the Barbary powers, not least a pledge to treat Christian captives prisoners of war rather than slaves, as the pretext for the Palma raid was a "war" between Tunis and the Kingdoms of Sardinia and Sicily.
The bombardment of Algiers, 1816
Exmouth´s diplomacy had appeared to work, with agreement form all parties, only for a group of Sardinian fishermen to be attacked and massacred. Fed up with this, Exmouth returned with an Anglo-Dutch squadron and on August 17th 1816 bombarded Algiers. Following this Algiers and Tunis signed new treaties.
And again slave raiding continued, with another bombardment of Algiers in 1824 by a British fleet under Admiral Sir Harry Neal (it´s amazing there were any buildings still standing by now), but the scourge was only ended for good with the occupation and annexation of Algiers by the French in 1830.
The Tunisian fleet was defeated by the British in 1826 and by the French in 1827, but perhaps because it was technically under Ottoman Turkish protection, the city was not occupied until the French arrived in 1881.
Tripoli had long been, technically, part of the Ottoman empire, but infact was ruled by the descendants of a Janissary rebellion. However in 1835 the Ottomans took back control, and Tripoli was part of the Empire until conquered by the Italians in 1911 during the Italo-Turkish War.