Born in Boston, Massachusetts, Porter served in the Quasi-War with France first as midshipman aboard , participating in the capture of "L'Insurgente" on February 9, 1799; then as 1st lieutenant of ; and finally in command of USS "Amphitheatre". During the First Barbary War (1801–07), Porter was first lieutenant of , , and and was taken prisoner when the latter ran aground in Tripoli harbor on October 31, 1803. After his release on June 3, 1805, he remained in the Mediterranean as acting captain of and later captain of "Enterprise".