In February 1804, he was second in command during the expedition to destroy the captured frigate USS Philadelphia. Later in the conflict he commanded Enterprise and a gunboat in battles with the Tripolitans. He was also First Lieutenant of the frigate Adams and, in 1805, commanded the small Gunboat No. 6 during a voyage across the Atlantic to North Africa.