Tripoli, helped to maintain the blockade of Tripoli, and distinguished himself in assaults on the enemy in August and September 1804. After the First Barbary War, he participated in a show of force at Tunis. He was second in command to Preble from 1803 through 1805. He was promoted to the rank of captain on 22 April 1806 and returned home on leave from US Navy, joining the merchant fleet, where he remained until the late 1811. War of 1812 During the War of 1812, Stewart commanded, successively, , , and . Since Constellation was closely blockaded in Norfolk by the British, he took command of Constitution ("Old Ironsides") at Boston on 18 July 1813. He made two brilliant cruises in her between 1813 and 1815. Under Stewart's command, Constitution captured and on 20 February 1815. The Treaty of Ghent had been ratified by the United States government three days earlier but both sides in the battle were unaware of that event. By capturing two British warships with a single ship of his own, Stewart became a national hero and was awarded a Congressional Gold Medal on 22 February 1816. He was also admitted as an honorary member of the Pennsylvania Society of the Cincinnati in the same year. Postwar career Stewart's later service included command of the American Mediterranean squadron from 1816 to 1820 and of one in the Pacific from 1820 to 1824. For South American patriots fighting for their independence, commodore Stewart's conduct in Peruvian waters was controversial because, claiming "neutral rights" for U.S. merchants, he escorted their ships through a patriot blockade to trade with Spanish royalists. His flagship, the USS Franklin, also transported a Spanish spy. (Stewart said he was unaware the Spaniard was on his ship, and he blamed his wife for secreting the man on board.) For these and other actions, the U.S. Navy subjected Stewart to a highly publicized court-martial upon return to the United States. Stewart's wife refused to testify in his defense, and they soon divorced. Stewart biographers Berube and Rodgaard concluded about his trial that, “the Navy desperately needed a not-guilty verdict as several of its senior-most captains faced courts-martial in the summer of 1825.” A board of twelve of Stewart's fellow officers found him not guilty. Stewart served as a Naval Commissioner from 1830 to 1832. In 1836 Stewart saw service in the West Indies and commanded a