McHenry was born at Ballymena, County Antrim, Ireland, in 1753. He enjoyed a classical education at Dublin, and emigrated to Philadelphia in 1771. The following year, the rest of his family came to the colonies, and his brother and father established an import business at Baltimore. During that year, James continued schooling at Newark Academy in Delaware and then studied medicine for 2 years under the well-known Dr. Benjamin Rush in Philadelphia.
During the War for Independence, McHenry served as a military surgeon. Late in 1776, while he was on the staff of the 5th Pennsylvania Battalion, the British captured him at Fort Washington, NY. He was paroled early the next year and exchanged in March 1778. Returning immediately to duty, he was assigned to Valley Forge, PA, and in May became secretary to George Washington. About this time, McHenry apparently quit the practice of medicine to devote himself to politics and administration; he apparently never needed to return to it after the war because of his excellent financial circumstances.
McHenry stayed on Washington's staff until 1780, when he joined that of the Marquis de Lafayette, and he remained in that assignment until he entered the Maryland Senate (1781-86). During part of this period, he served concurrently in the Continental Congress (1783-86). In 1784 he married Margaret Allison Caldwell.
McHenry missed many of the proceedings at the Philadelphia convention, in part because of the illness of his brother, and played an insubstantial part in the debates when he was present. He did, however, maintain a private journal that has been useful to posterity. He campaigned strenuously for the Constitution in Maryland and attended the state ratifying convention.
From 1789 to 1791, McHenry sat in the state assembly and in the years 1791-96 again in the senate. A staunch Federalist, he then accepted Washington's offer of the post of Secretary of War and held it into the administration of John Adams. McHenry looked to Hamilton rather than to Adams for leadership. As time passed, the latter became increasingly dissatisfied with McHenry's performance and distrustful of his political motives and in 1800 forced him to resign. Subsequently, the Democratic-Republicans accused him of maladministration, but a congressional committee vindicated him.
McHenry returned to his estate near Baltimore and to semiretirement. He remained a loyal Federalist and opposed the War of 1812. He also held the office of president of a Bible society. He died in 1816 at the age of 62, survived by two of his three children. His grave is in Baltimore's Westminster Presbyterian Cemetery.