The Barbary States were the North African regencies of Algiers, Tunis, and Tripoli, ruled under loose Ottoman suzerainty from the 16th to the early 19th century. The very name Barbary, from the Berbers of the coast, became a byword in Europe for piracy, and these states matter because for three centuries their corsairs made every power on the Mediterranean pay attention, and pay up.
The corsairs were the engine of the system: swift galleys out of Algiers and Tunis raided shipping and coasts from Spain to Iceland, seizing cargoes and captives who were ransomed, sold, or put to the oars. The Ottomans had a genius for recruiting their enemies: many of the most feared corsair captains were European renegades, men like Yusuf Rais, born Jack Birdy in England, who turned their skills to the Barbary flag. European states found it cheaper to pay annual tribute for safe passage than to fight, and even the new United States, fresh from revolution, paid protection money until President Jefferson sent warships instead.
Fighting came in waves: American squadrons battled Tripoli from 1801 and returned under Decatur in 1815 to force an end to tribute, while a British fleet under Lord Exmouth bombarded Algiers in 1816 to free Christian captives. Each blow weakened the corsair economy, and the rulers, deys in Algiers, beys in Tunis, pashas and local dynasties in Tripoli, could no longer command the sea that fed them.
The end came from France: in 1830 a French army landed and took Algiers, beginning a conquest of Algeria that would last generations and opening the door to the European colonization of North Africa. The Barbary system collapsed with it, and the old corsair ports became colonial cities.