After he was released by the British, Gregory joined the Mediterranean Squadron and operated along the North African coast until 1S21. In that year he became captain of Grampus and spent the following two years cruising the West Indies, to suppress piracy. While in the Indies. Gregory captured the notorious pirate brig Panchita and destroyed several other pirate ships. After fitting out, the frigate Brandywine, destined to carry LaFayette back to France, in 1824, Gregory sailed a 64 gun frigate to Greece for the revolutionary government. From 1824–1828 he served at the New York Navy Yard, and in 1831 reported to the Pacific Station for a 3-year cruise in command of Falmouth. Gregory served as commander of the Station for one year.
From the Pacific, Gregory—appointed a captain in 1838—sailed to the Gulf of Mexico, where he commanded North Carolina and Raritan and served in the blockade of the Mexican coast during the war with that country. After the Mexican War, Gregory commanded the squadron off the African coast, with Portsmouth as his flagship, until June 1851. Returning to the States, he became Commandant of the Boston Navy Yard in May 1852 and served there through February 1856. His subsequent retirement ended a navy career which spanned nearly 50 years. When the bloody Civil War rolled across the land, Gregory returned to naval service to superintend the building and fitting out of naval vessels in private shipyards. Promoted to Rear Admiral 16 July 1862, he served throughout the 4 years of war and then retired again.
Admiral Gregory died 4 October 1866 in Brooklyn, and was buried at New Haven.
Source: Naval History & Heritage Command including Dictionary of American Naval Fighting Ships