In 1840 Stuart won election as a Whig to the 27th Congress, as the incumbent Jacksonian Democrat Robert Craig declined to run for re-election. He defeated Democrat and future Virginia governor James McDowell in that election. Stuart served on the committee concerning the Navy Department, and beginning in February 1842 on the Committee on Foreign Affairs. He was one of only two Southern representatives to support former President John Quincy Adams when Adams proposed to end the rule forbidding petitions against slavery. After President William Henry Harrison's death, Stuart criticized the new President, fellow Virginian John Tyler for opposing a new national bank, and also supported a tariff to protect American (and Virginia) manufacturers. In 1843, post-census redistricting combined his district with Virginia's 11th congressional district held by John Minor Botts; Democrat William Taylor defeated Stuart and won election to the 28th Congress. However, Stuart continued politically active, serving as a presidential elector for the Whig ticket in both 1844 (when it lost) and 1848 (when it won).