Pirates ransomed American sailors for decades until Jefferson sent the Navy
For years the US paid tribute to North African Barbary states to stop corsairs seizing American merchant ships and enslaving their crews. In 1801, newly inaugurated President Thomas Jefferson refused to keep paying Tripoli's rising demands, triggering the First Barbary War. US sailors and Marines, including Stephen Decatur's raid to burn the captured USS Philadelphia, forced a settlement by 1805 — later commemorated in the Marine Corps hymn's 'shores of Tripoli'.
— Wikipedia contributors, Barbary Wars — First Barbary War, 1801–1805