The Barbary Wars were a series of two wars fought by the United States, Sweden, and the Kingdom of Sicily against the Barbary states (including Tunis, Algiers, and Tripoli) and Morocco of North Africa in the early 19th century. Sweden had been at war with the Tripolitans since 1800 and was joined by the newly independent US. The First Barbary War extended from 10 May 1801 to 10 June 1805, with the Second Barbary War lasting only three days, ending on 19 June 1815.

The wars were largely a reaction to piracy carried out by the Barbary states. Since the 16th century, North African pirates captured ships and even raided cities across the Mediterranean Sea. By the 19th century, pirate activity had declined, but Barbary pirates continued to demand tribute from American merchant vessels in the Mediterranean. Refusal to pay would result in the capturing of American ships and goods, and often the enslavement or ransoming of crew members.

After Thomas Jefferson became president of the US in March 1801, he sent a US Naval fleet to the Mediterranean to combat the Barbary pirates. The fleet bombarded numerous fortified cities in present-day Libya, Tunisia, and Algeria, ultimately extracting concessions of safe conduct from the Barbary states and ending the first war. 

During the War of 1812, with the encouragement of the United Kingdom, the Barbary corsairs resumed their attacks on American vessels. Following the conclusion of the War of 1812 and America's attainment of peace with Britain, James Madison, Jefferson's successor, directed military forces against the Barbary states in the Second Barbary War. Lasting only three days, the second conflict ended the need for further tributes by the United States, granted the U.S. full shipping rights in the Mediterranean Sea, and significantly reduced incidents of piracy in the region.

Background
The Barbary corsairs were pirates and privateers who operated out of North Africa, based primarily in the ports of Tunis, Tripoli, and Algiers. This area was known in Europe as the Barbary Coast, in reference to the Berbers. Their predation extended throughout the Mediterranean, south along West Africa's Atlantic seaboard and even to the eastern coast of South America with Brazil, and into the North Atlantic Ocean as far north as Iceland, but they primarily operated in the western Mediterranean. In addition to seizing ships, they engaged in razzias, raids on European coastal towns and villages, mainly in Italy, France, Spain, and Portugal, but also in England, Scotland, the Netherlands, Ireland, and as far away as Iceland. The main purpose of their attacks was to capture Europeans for the slave market in North Africa.

The Barbary states were nominally part of the Ottoman Empire, but in practice they were independent and the Ottoman government in Constantinople was not involved.

Attacks
Since the 1600s, the Barbary pirates had attacked British shipping along the North Coast of Africa, holding captives for ransom or enslaving them.  Ransoms were generally raised by families and local church groups. The British became familiar with captivity narratives written by Barbary pirates' prisoners and slaves.

During the American Revolutionary War, the pirates attacked American ships. On December 20, 1777, Morocco's sultan Mohammed III declared that merchant ships of the new American nation would be under the protection of the sultanate and could thus enjoy safe passage into the Mediterranean and along the coast. The Moroccan-American Treaty of Friendship stands as America's oldest unbroken friendship treaty with a foreign power. In 1787, Morocco became one of the first nations to recognize the United States of America.

Starting in the 1780s, realizing that American vessels were no longer under the protection of the British navy, the Barbary pirates had started seizing American ships in the Mediterranean. As the U.S. had disbanded its Continental Navy and had no seagoing military force, its government agreed in 1786 to pay tribute to stop the attacks. On March 20, 1794, at the urging of President George Washington, Congress voted to authorize the building of six heavy frigates and establish the United States Navy, in order to stop these attacks and demands for more and more money. The United States had signed treaties with all of the Barbary states after its independence was recognized between 1786–1794 to pay tribute in exchange for leaving American merchantmen alone, and by 1797, the United States had paid out $1.25 million or a fifth of the government's annual budget then in tribute. These demands for tribute had imposed a heavy financial drain and by 1799 the U.S. was in arrears of $140,000 to Algiers and some $150,000 to Tripoli. Many Americans resented these payments, arguing that the money would be better spent on a navy that would protect American ships from the attacks of the Barbary pirates, and in the 1800 Presidential Election, Thomas Jefferson won against incumbent second President John Adams, in part by noting that the United States was "subjected to the spoliations of foreign cruisers" and was humiliated by paying "an enormous tribute to the petty tyrant of Algiers".

First Barbary War (1801–1805)

The First Barbary War (1801–1805), also known as the Tripolitian War or the Barbary Coast War, was the first of two wars fought between the alliance of the United States and several European countries against the Northwest African Muslim states known collectively as the Barbary states. These were Tripoli and Algiers, which were quasi-independent entities nominally belonging to the Ottoman Empire, and (briefly) the independent Sultanate of Morocco. This war began during Thomas Jefferson's term when he refused to pay tribute, an amount that was greatly increased when he became president. A U.S. naval fleet was sent on May 13, 1801, at the beginning of the war under the command of Commodore Richard Dale. Other notable officers in the fleet included Stephen Decatur, assigned to the frigate  and William Bainbridge in command of Essex which was attached to Commodore Richard Dale's squadron which also included ,  and .

During this war, the ship Philadelphia was blockading Tripoli's harbor when she ran aground on an uncharted reef. Under fire from shore batteries and Tripolitan gunboats, the Captain, William Bainbridge, tried to refloat her by casting off all of her guns and other objects that weighed it down. The ship was eventually captured and the crew taken prisoners and put into slavery. To prevent this powerful war ship from being used by the Barbary pirates the ship was later destroyed by a raiding party of American Marines and soldiers and allied sailors from the armed forces of King Ferdinand of Sicily, led by Stephen Decatur.

Second Barbary War (1815)

The Second Barbary War (1815), also known as the Algerine or Algerian War, was the second of two wars fought between the United States and the Ottoman Empire's North African regencies of Tripoli, Tunis and Algeria, known collectively as the Barbary states. The war between the Barbary states and the U.S. ended in 1815; the international dispute would effectively be ended the following year by the United Kingdom and the Netherlands. The war brought an end to the American practice of paying tribute to the pirate states and helped mark the beginning of the end of piracy in that region, which had been rampant in the days of Ottoman domination (16th–18th centuries). Within decades, European powers built ever more sophisticated and expensive ships which the Barbary pirates could not match in numbers or technology.

Effect in United States

When the United States military efforts of the early 19th century were successful against the pirates, partisans of the Democratic-Republicans contrasted their presidents' refusals to buy off the pirates by paying tribute with the failure of the preceding Federalist administration to suppress the piracy. The Federalist Party had adopted the slogan, "Millions for defense, but not one cent for tribute," but had failed to end the attacks on merchant ships. From 1796 to 1797 French raiders seized some 316 American merchant ships flying American colors. To counter this ongoing advent three frigates, ,  and , were soon built to answer the call for security.

See also
 Algeria–United States relations
 Libya–United States relations
 Morocco–United States relations
 Ottoman Empire–United States relations
 Tunisia–United States relations
 Turkey–United States relations

References

Bibliography
  E'book
 
 . E'book
  Book (par view) 

, Book (par view)
 Book (par view)

Further reading
 Allison, Robert. The Crescent Obscured: The United States and the Muslim World, 1776-1815 (2000)
 Bak, Greg. Barbary Pirate: The Life and Crimes of John Ward (The History Press, 2010) about Jack Ward in earlier times.
 Banham, Cynthia, and Brett Goodin. "Negotiating Liberty: The Use of Political Opportunities and Civil Society by Barbary State Captives and Guantánamo Bay Detainees." Australian Journal of Politics & History 62.2 (2016): 171-185 online.
 Boot, Max. The Savage Wars of Peace: Small Wars and the Rise of American Power. New York: Basic Books, 2002. 
 Bow, C. B. "Waging War for the Righteous: William Eaton on Enlightenment, Empire, and Coup d'état in the First Barbary War, 1801–1805." History 101.348 (2016): 692–709. Argues  that the First Barbary War was not a 'Holy War' nor the first American war on Islamic terrorism. online
 Castor, Henry. The Tripolitan war, 1801-1805; America meets the menace of the Barbary pirates (1971) online
 Chidsey, Donald Barr. The wars in Barbary; Arab piracy and the birth of the United States Navy (1971) online, popular history
 Colás, Alejandro. "Barbary Coast in the expansion of international society: Piracy, privateering, and corsairing as primary institutions." Review of International Studies 42.5 (2016): 840-857 online.
 Crane, Jacob. "Barbary (an) Invasions: The North African Figure in Republican Print Culture." Early American Literature 50.2 (2015): 331-358 online.
 Crane, Jacob. "Peter Parley in Tripoli: Barbary Slavery and Imaginary Citizenship." ESQ: A Journal of Nineteenth-Century American Literature and Culture 65.3 (2019): 512-550 online.
 Davis, Robert C. Christian slaves, Muslim masters: white slavery in the Mediterranean, the Barbary Coast, and Italy, 1500-1800 (2004) online
 Edwards, Samuel.  Barbary General: the life of William H. Eaton  (1968) online, popular history
 Fullmer, Jason. "Jeffersonian Nationalism vs. Enlightenment: Securing American Core Values amidst the Barbary Wars, 1801–1809." Crescast Scientia (2016): 37–54. online.
 Gawalt, Gerard W.  "America and the Barbary pirates: An international battle against an unconventional foe." Thomas Jefferson Papers (Library of Congress, 2011) online.
 Jamieson, Alan G. Lords of the sea: a history of the Barbary corsairs (Reaktion Books, 2013).
 Kilmeade, Brian and Yeager, Don. "Thomas Jefferson and the Tripoli Pirates" (Sentinel, 2015)
 Kitzen, Michael L. S. Tripoli and the United States at War: A History of American Relations with the Barbary States, 1785-1805 (McFarland, 1993).
 Lambert, Frank. The Barbary Wars. (Hill and Wang, 2005).
 Lardas, Mark. American Light and Medium Frigates 1794–1836 (Bloomsbury Publishing, 2012).
 London, Joshua E. Victory in Tripoli: How America's War with the Barbary Pirates Established the U.S. Navy and Shaped a Nation. (John Wiley & Sons,  2005). 
 Murphy, Martin N. "The Barbary Pirates." Mediterranean Quarterly 24.4 (2013): 19–42. online
 Oren, Michael B. Power, Faith, and Fantasy: America in the Middle East, 1776 to the Present (2007)
 Page, Kate. "Those Pirates and Muslim Barbarians: The American Public View of the Barbary Nations and the United States Participation in the Barbary War." Fairmount Folio: Journal of History 13 (2011) pp 21–34.online.
 Panzac, Thomas.  The Barbary Corsairs: The End of a Legend, 1800-1820 (E.J.Brill, 2002)
 Peskin, Lawrence A. Captives and Countrymen: Barbary Slavery and the American Public, 1785–1816 (Johns Hopkins University Press. 2009). 256pp
 Rejeb, Lotfi Ben. "‘The general belief of the world’: Barbary as genre and discourse in Mediterranean history." European Review of History 19.1 (2012): 15-31.
 Ribeiro, Jorge Martins. "Conflict and peace in the Mediterranean: barbary privateering in the late 18th and early 19th centuries." in Borders and conflicts in the Mediterranean Basin (2016). online
 Sayre, Gordon M. "Renegades from Barbary: The Transnational Turn in Captivity Studies." American Literary History 22.2 (2010): 347–359 on converts to Islam.
 Schifalacqua, John F. "James Madison and America's First Encounter with Islam: Tracing James Madison's Engagement with Barbary Affairs Through the 1st Barbary War." Penn History Review 21.1 (2014) online.
 Tinniswood, Adrian. Pirates of Barbary: Corsairs, Conquests and Captivity in the Seventeenth-Century Mediterranean ( Riverhead, 2010), about the earlier period.
 Turner, Robert F. "President Thomas Jefferson and the Barbary Pirates." In Bruce A Elleman, et al. eds., Piracy and Maritime Crime: Historical and Modern Case Studies (2010): 157–172.   online
 Vick, Brian. "Power, Humanitarianism and the Global Liberal Order: Abolition and the Barbary Corsairs in the Vienna Congress System." International History Review 40.4 (2018): 939–960.
 Walther, Karine V. Sacred Interests: The United States and the Islamic World, 1821–1921 (University of North Carolina Press, 2015) 457pp online review
 Whipple, A. B. C. To the Shores of Tripoli: The Birth of the U.S. Navy and Marines. Bluejacket Books, 1991. 
 Wolfe, Stephen. "Borders, Bodies, and Writing: American Barbary Coast Captivity Narratives, 1816-1819." American Studies in Scandinavia 43.2 (2011): 5-30 online
 Wright, Louis B. and Julia H Macleod. The First Americans in North Africa: William Eaton's Struggle for a Vigorous Policy Against the Barbary Pirates, 1799–1805 (Princeton UP, 1945), 227pp

Primary sources
 Baepler, Paul ed. White Slaves, African Masters: An Anthology of American Barbary  Captivity Narratives (The University of Chicago Press, 1999).

External links
 The Barbary Wars at the Clements Library:An online exhibit on the Barbary Wars with images and transcriptions of primary documents from the period.

 
19th-century conflicts
History of international relations
History of the foreign relations of the United States
19th century in Africa
1800s in the United States
1815 in the United States
Piracy in the Mediterranean
Wars involving the United States
United States Marine Corps in the 18th and 19th centuries
Anti-slavery military operations