Ramsey was born in Lancaster County, Pennsylvania. He was the elder brother of David Ramsay, though the brothers spelled their name differently. He graduated from the College of New Jersey (later Princeton University) in 1767 and then read law. He settled in northeastern Maryland, and was admitted to the bar in Cecil County in 1771.
At the Battle of Monmouth, in June 1778, Ramsey was asked by General Washington to stop the British advance after General Lee's initial retreat, and gain time for Washington to rally his other troops. He did so, but his regiment took heavy casualties. Ramsey himself was seriously wounded, left for dead, and taken prisoner. By the time he was exchanged, his regiment had gone south with General Nathanael Greene's forces. He returned to Maryland, and his only remaining military role was in recruiting. He retired from the army on January 1, 1781, and resumed the practice of law in Cecil County.
Ramsey moved to Baltimore, Maryland in 1783, and practiced law there. He represented Maryland in the Congress of the Confederation in New York in 1786 and 1787. After the establishment of the Federal government in 1789, President Washington appointed him the first U.S. Marshal for the District of Maryland, with his offices in Baltimore. He held this post from 1790 to 1798. In addition, he was named as Port Captain for Baltimore, serving from 1794 until his death in 1817. He died in Baltimore and is buried in Westminster Hall and Burying Ground.