The merchant and farmer Gregg was a member of the Congress of the United States from 1791 to 1813, first on 24 October 1791 to March 3, 1807 the House of Representatives, after October 26, 1807 to March 3, 1813 as a senator. In the Senate, Gregg officiated during the 11th Congress as president pro tempore. In 1816 he was appointed Secretary of State for Pennsylvania. 1823 Gregg ran unsuccessfully for the office of governor of Pennsylvania. Prior to his election to Congress in Gregg had taken part in the American Revolution as a member of the militia of Delaware. From 1779 to 1783 he was a lecturer at the College of Philadelphia.
Two townships in Pennsylvania have been named after Gregg. One was founded in 1826 and is located in Centre County, the other, founded in 1865, in Union County ( formerly a part of Lycoming County).
Andrew Gregg was married to a daughter of Brigadier General James Potter. Gregg's father, also named Andrew, was involved as a member of the Paxton Boys massacres of 1763 on the Susquehannock Indians at Lancaster. Gregg Andrew Gregg Curtin and grandson James Xavier McLanahan were also known Pennsylvanian African politicians.