On 9 March 1798 during the Quasi-War with France, Stewart was commissioned a lieutenant in the United States Navy and joined the frigate United States for a cruise in the West Indies. He took command of the schooner Experiment on 16 July 1800 and soon captured two armed French vessels and freed several captured American ships. After brief command of Chesapeake in 1801 and service in Constellation in 1802, Stewart sailed to the Mediterranean in command of the brig Siren. There he participated in the destruction of Philadelphia after her capture by Tripoli, helped to maintain the blockade of Tripoli and distinguished himself in assaults on the enemy in August and September 1804. After the war, he participated in a show of force at Tunis and returned home as captain in 1806.
On the outbreak of war in 1812, Stewart commanded, successively, Argus, Hornet, and Constellation. As the latter was closely blockaded in Norfolk, however, heassumed command of Constitution at Boston in 1813. He made two brilliant cruises in her between 1813 and 1815 and on 20 February 1815, captured HMS Cyane and HMS Levant.
Stewart’s later service included command of a squadron in the Mediterranean from 1816 to 1820 and of one in the Pacific from 1820 to 1824. He served as a Naval Commissioner from 1830 to 1832 and commanded the Philadelphia Navy Yard from 1838 to 1841, in 1846, and again from 1854 to 1861. By a bill passed on 2 March 1859, Congress made Stewart “senior flag officer,” an office created for him in recognition of his distinguished and meritorious service.
He became rear admiral on the retired list on 16 July 1862 and died at Bordentown, New Jersey on 6 November 1869.