In 1796, Karamanli drafted and signed the Treaty of Tripoli, which permitted the passage of American commercial ships through Tripolitanian waters.
Jefferson, confident in the ability of the fledgling United States Navy (newly reinforced with the building of six heavy frigates beginning in 1797) to protect American shipping, refused the Pasha's demands.
He signed a treaty with American emissary Tobias Lear of the U.S. Department of State that officially ended the war on 10 June 1805.
[4][5] By 1819, the various treaties of the Napoleonic Wars had forced the Barbary states to give up corsair activity almost entirely, and Tripoli's economy began to crumble.
[1] Karamanli attempted to compensate for lost revenue by encouraging the trans-Saharan slave trade, but with abolitionist sentiment on the rise in Europe and to a lesser degree in the United States, this failed to salvage Tripoli's economy.