Apparently, the Barbary Pirates had been working off North African Coast, capturing ships and their crews since the days of the Crusades, 1095 – 1291. Nations had grown accustomed to dealing with them the easy way, paying ransom.
In 1801 Pasha,, a high-ranking military officer, discovered the United States was paying him less than the others and declared war on the United States. Jefferson paused from his mothballing of navy ships, assembled a fleet, and without permission Congress he declared war on the pirates and sailed for North Africa.
The war was in its second year when an American naval officer sailed to Tripoli, set fire to the Algerian Navy ships, and reclaimed the Philadelphia and rescued the crew members were held hostage. Then, in revenge for his brother’s death he engaged them in hand-to-hand. The feat was so remarkable that Lord Nelson declared it the rescue of the age, or words to that effect.
When the war was finished the navy returned and Jefferson resumed his mothballing.