In 1760, he adopted Philadelphia, Pennsylvania, as his permanent residence. Remaining active in the seagoing trade, he had command of the merchantman Black Prince in 1775 and assisted in her entry into the Continental service under the name Alfred. He commanded the Continental brig Lexington during the first part of 1776, capturing several British vessels. Later in the year, he received the rank of Captain in the Continental Navy and was appointed Commanding Officer of the new frigate Effingham. Though his ship was unable to get to sea, Barry used her armament and men effectively during the long campaign to defend the Philadelphia region against greatly superior British forces.
In 1778, Captain Barry commanded the frigate Raleigh. His gallant conduct in her loss in September 1778 ensured that he received further active employment.
After a time as captain of a privateer, in 1780 he was given the frigate Alliance, in which he captured HMS Atalanta, HMS Trepassy and other enemy privateers warships between 1781 and 1783. Alliance also carried American diplomats across the Atlantic to France and performed valuable services in the Caribbean Sea.
Following the end of the Revolutionary War in 1783, Barry returned to the merchant service.
In 1794 he was appointed the senior Captain of the newly established United States Navy and subsequently was in charge of constructing the large frigate United States. Captain Barry commanded the new ship in the West Indies during the 1798–1801 Quasi-War with France, including a period as Commodore of U.S. Navy forces in the region. He served ashore at Philadelphia for the remainder of his life.
Commodore Barry died at Strawberry Hill, near Philadelphia, 13 September 1803 and is buried in St. Mary’s Cemetery, Philadelphia.