Within days of his March 1801 inauguration as the third President of the United States, Thomas Jefferson ordered a naval and military expedition to North Africa, without the authorization of Congress, to put down regimes involved in slavery and piracy. The war was the first in which the U.S. flag was carried and planted overseas; it saw the baptism by fire of the U.S. Marine Corps--whose anthem boasts of action on "the shores of Tripoli"--and it prefigured later struggles with both terrorism and jihad.
The Barbary States of North Africa--Algiers, Tunis, Morocco and Tripoli (today's Libya)--had for centuries sustained themselves by preying on the maritime commerce of others. Income was raised by direct theft, the extortion of bribes or "protection" and the capture of crews and passengers to be used as slaves. The historian Robert Davis, in his book Christian Slaves, Muslim Masters: White Slavery in the Mediterranean, the Barbary Coast and Italy, 1500-1800, estimates that as many as 1.25 million Europeans and Americans were enslaved. The Barbary raiders--so called because they were partly of Berber origin--struck as far north as England and Ireland. It appears, for example, that almost every inhabitant of the Irish village of Baltimore was carried off in 1631. Samuel Pepys and Daniel Defoe both mention the frightening trade in their writings; at that time, pamphlets and speeches by survivors and escaped slaves had a huge influence on the popular imagination. James Thomson's famously rousing 1740 song Rule Britannia, with its chorus about how Britons "never shall be slaves," was a direct allusion to the Barbary terrorism.
Jefferson was appalled by this practice from an early stage of his career. In 1784 he wrote to James Madison about the Barbary depredations, saying, "We ought to begin a naval power, if we mean to carry on our commerce. Can we begin it on a more honorable occasion or with a weaker foe?" He added that John Paul Jones, the naval hero of the Revolutionary War, "with half a dozen frigates" could subdue the slave kingdoms of North Africa.
The year 1784 saw the American brig Betsey, with her crew of 10, captured by a Moroccan corsair while sailing with a cargo of salt from Spain to Philadelphia. Soon after, Algerian pirates grabbed the Dauphin and the Maria on the high seas of the Atlantic and took their crews captive. The situation was becoming worse because the British fleet had withdrawn protection of American vessels after the former colony declared its independence, and the U.S. had no navy of its own. Secretary of State John Jay decided to do what the European powers did and pay tribute to the Barbary sultans in exchange for safe passage as well as for the return of captured American slaves.