He was promoted captain following his daring recapture of the frigate Philadelphia in the Tripolitan War (1801–05). After the War of 1812 he became a national hero by forcing the Bey (ruler) of Algiers to sign the treaty (1815) that ended US tribute to the Barbary pirates. He was killed in a duel with a suspended naval officer.