During the War of 1812, he returned to the United States and privateering against the British. In 1814 he was recommissioned in the USN and placed in command of a flotilla of small boats charged with the defence of Chesapeake Bay. When the British overcame his flotilla, Barney took his men and guns overland to fight in the battle of Bladensburg, an unsuccessful effort to stop the British forces that eventually occupied the city of Washington and burned the White House. During the battle of Bladensburg, Barney was severely wounded and captured. The British treated him well and cared for his wound, and he was paroled. In 1815 he carried dispatches that were part of the final negotiations after the Treaty of Ghent ended the War of 1812. In his last Navy assignment he served as Naval Officer of the Port of Baltimore, 1817-18.