If you're like me, when you picture America in the late 1700's and early 1800's, you don't picture swashbuckling battles with pirates. However, that was one of the main foreign policy challenges of the young republic.
Early on, the vast ocean that protected America from foreign attack also made its shipping more susceptible to attacks by pirates.
The 'Barbary states' which were mainly in territories in North Africa which are now Libya, Algeria and Morocco became so bold at one point that they demanded tribute from the United States Government in order to offer 'protection' of its ships in the Mediterranean.
At that point, Jefferson, failing to create an international alliance with France or Britain, actually declared war on the Barbary states. We invaded Tripoli (sound familiar?) and threatened to topple the war lord/sheik in charge there unless they released our ships and stopped attacking our commerce.
It's funny that even today, piracy in the traditional sense exists in the age of airplanes and GPS. It's hard to imagine how much of a threat it was when a compass and the stars were the height of navigation technology.