Background and overview
Barbary corsairs and crews from the North African Ottoman provinces of Algiers, Tunis, Tripoli, and the independent Sultanate of Morocco under the Alaouite dynasty (the Barbary Coast) were the scourge of the Mediterranean. Capturing merchant ships and enslaving or ransoming their crews provided the Muslim rulers of these nations with wealth and naval power. The Roman Catholic Trinitarian Order, or order of "Mathurins", had operated from France for centuries with the special mission of collecting and disbursing funds for the relief and ransom of prisoners of Mediterranean pirates. According to Robert Davis, between 1 and 1.25 million Europeans were captured by Barbary pirates and sold as slaves between the 16th and 19th centuries.
Barbary corsairs led attacks upon American merchant shipping in an attempt to extort ransom for the lives of captured sailors, and ultimately tribute from the United States to avoid further attacks, as they did with the various European states. Before the Treaty of Paris, which formalized the United States' independence from Great Britain, U.S. shipping was protected by France during the revolutionary years under the Treaty of Alliance (1778–83). Although the treaty does not mention the Barbary States in name, it refers to common enemies between both the U.S. and France. As such, piracy against U.S. shipping only began to occur after the end of the American Revolution, when the U.S. government lost its protection under the Treaty of Alliance.
This lapse of protection by a European power led to the first American merchant ship being seized after the Treaty of Paris. On 11 October 1784, Moroccan pirates seized the brigantine Betsey. The Spanish government negotiated the freedom of the captured ship and crew; however, Spain advised the United States to offer tribute to prevent further attacks against merchant ships. The U.S. Minister to France, Thomas Jefferson, decided to send envoys to Morocco and Algeria to try to purchase treaties and the freedom of the captured sailors held by Algeria. Morocco was the first Barbary Coast State to sign a treaty with the U.S., on 23 June 1786. This treaty formally ended all Moroccan piracy against American shipping interests. Specifically, article six of the treaty states that if any Americans captured by Moroccans or other Barbary Coast States docked at a Moroccan city, they would be set free and come under the protection of the Moroccan State.
American diplomatic action with Algeria, the other major Barbary Coast State, was much less productive than with Morocco. Algeria began piracy against the U.S. on 25 July 1785 with the capture of the schooner Maria, and Dauphin a week later. All four Barbary Coast states demanded $660,000 each. However, the envoys were given only an allocated budget of $40,000 to achieve peace. Diplomatic talks to reach a reasonable sum for tribute or for the ransom of the captured sailors struggled to make any headway. The crews of Maria and Dauphin remained enslaved for over a decade, and soon were joined by crews of other ships captured by the Barbary States.
In March 1786, Thomas Jefferson and John Adams went to London to negotiate with Tripoli's envoy, ambassador Sidi Haji Abdrahaman (or Sidi Haji Abdul Rahman Adja). When they enquired "concerning the ground of the pretensions to make war upon nations who had done them no injury", the ambassador replied:
It was written in their Koran, (that all nations which had not acknowledged the Prophet were sinners, whom it was the right and duty of the faithful to plunder and enslave; and that every mussulman who was slain in this warfare was sure to go to paradise). He said, also, that the man who was the first to board a vessel had one slave over and above his share, and that when they sprang to the deck of an enemy's ship, every sailor held a dagger in each hand and a third in his mouth; which usually struck such terror into the foe that they cried out for quarter at once.
Jefferson reported the conversation to Secretary of Foreign Affairs John Jay, who submitted the ambassador's comments and offer to Congress. Jefferson argued that paying tribute would encourage more attacks. Although John Adams agreed with Jefferson, he believed that circumstances forced the U.S. to pay tribute until an adequate navy could be built. The U.S. had just fought an exhausting war, which put the nation deep in debt.
Various letters and testimonies by captured sailors describe their captivity as a form of slavery, even though Barbary Coast imprisonment was different from that practiced by the U.S. and European powers of the time. Barbary Coast prisoners were able to obtain wealth and property, along with achieving status beyond that of a slave. One such example was James Leander Cathcart, who rose to the highest position a Christian slave could achieve in Algeria, becoming an adviser to the bey (governor). Even so, most captives were pressed into hard labor in the service of the Barbary pirates, and struggled under extremely poor conditions that exposed them to vermin and disease. As word of their treatment reached the U.S., through freed captives' narratives and letters, Americans pushed for direct government action to stop the piracy against U.S. ships.
On July 19, 1794, Congress appropriated $800,000 for the release of American prisoners and for a peace treaty with Algiers, Tunis, and Tripoli. On September 5, 1795, American negotiator Joseph Donaldson signed a peace treaty with the Dey of Algiers, that included an upfront payment of $642,500 in specie (silver coinage) for peace, the release of American captives, expenses, and various gifts for the Dey's royal court and family. An additional indefinite yearly tribute of $21,600 in shipbuilding supplies and ammunition would be given to the Dey. The treaty, designed to prevent further piracy, resulted in the release of 115 American sailors held captive by the Dey. 
1816 illustration of Christian slaves
Jefferson continued to argue for cessation of the tribute, with rising support from George Washington and others. With the recommissioning of the American Navy in 1794 and the resulting increased firepower on the seas, it became increasingly possible for America to refuse paying tribute, although by now the long-standing habit was hard to overturn. The continuing demand for tribute ultimately led to the formation of the United States Department of the Navy, founded in 1798 to prevent further attacks upon American shipping and to end the demands for extremely large tributes from the Barbary States. Federalist and Anti-Federalist forces argued over the needs of the country and the burden of taxation. Jefferson's own Democratic-Republicans and anti-navalists believed that the future of the country lay in westward expansion, with Atlantic trade threatening to siphon money and energy away from the new nation, to be spent on wars in the Old World. During the divisive election of 1800, Thomas Jefferson defeated President John Adams. Jefferson was sworn into office on March 4, 1801. The third President understood military force, rather than endless tributes, would be needed to resolve the Tripoli crisis.