<P> The turning point in the war was the Battle of Derna ( April -- May 1805 ) . Ex-consul William Eaton , a former Army captain who used the title of `` general '' , and US Marine Corps 1st Lieutenant Presley O'Bannon led a force of eight U.S. Marines and five hundred mercenaries -- Greeks from Crete , Arabs , and Berbers on a march across the desert from Alexandria , Egypt , to capture the Tripolitan city of Derna . This was the first time the United States flag was raised in victory on foreign soil . The action is memorialized in a line of the Marines ' Hymn -- `` the shores of Tripoli '' . The capturing of the city gave American negotiators leverage in securing the return of hostages and the end of the war . </P>
how did the us win the war against the barbary states
capture the Tripolitan city of Derna