The First Barbary War had begun four years earlier, when U.S. President Thomas Jefferson ordered U.S. Navy vessels to the Mediterranean Sea in protest of continuing raids against U.S. ships by pirates from the Barbary states–Morocco, Algeria, Tunis, and Tripolitania. American sailors were often abducted along with the captured booty and ransomed back to the United States at an exorbitant price. After two years of minor confrontations, sustained action began in June 1803, when a small U.S. expeditionary force attacked Tripoli harbor in present-day Libya.
In April 1805, a major American victory came during the Derna campaign, which was undertaken by U.S. land forces in North Africa. Supported by the heavy guns of the USS Argus and the USS Hornet, Marines and Arab mercenaries under William Eaton captured Derna and deposed Yusuf Karamanli. Lieutenant Presley O’ Bannon, commanding the Marines, performed so heroically in the battle that Hamet Karamanli presented him with an elaborately designed sword that now serves as the pattern for the swords carried by Marine officers. The phrase “to the shores of Tripoli,” from the official song of the U.S. Marine Corps, also has its origins in the Derna campaign.