Delegate and Congressman
Augusta County voters first elected Stuart as one of two men representing them in the Virginia House of Delegates in 1836. Re-elected twice as a Whig to what were then single-year terms (and a position which is still part-time), Stuart served on the Committee for Courts of Justice and also advocated internal improvements (the James River Canal as well as railroads). Although recommendations in his critical report concerning deficiencies in such improvements were not adopted, during 1838 Stuart became a junior member of the Committee on Roads and Internal Navigation.
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).
Stuart also resumed his legal practice full time. Beginning in 1849, he was one of the attorneys defending the new Wheeling Suspension Bridge, following a lawsuit in the United States Supreme Court brought by Edwin M. Stanton and Cornelius Darragh on behalf of the State of Pennsylvania and Pittsburgh, Pennsylvania interests that complained about obstruction of the Ohio River.
From 1850, Stuart served as United States Secretary of the Interior under new President Millard Fillmore for three years. That Department had been founded on the suggestion of one of his fellow counsel in the Wheeling Bridge case, and neither of his predecessors had lasted long. The department which consolidated the United States General Land Office, the Office of Indian Affairs, and the U.S. Patent Office also worked to resolve the boundary with Mexico. Stuart didn't change the culture of political patronage, but at least gave rules and standards to the political appointments and removed some of the administrative chaos until resigning as President Fillmore's term ended in 1853.
As the Whig Party disintegrated in 1852, Stuart declined to become its candidate in the U.S. Senate. Instead, he aligned himself with the nativist Know Nothing Party, which some criticized as secretly working against slavery. When Virginia's Democratic governor Henry A. Wise criticized the Know Nothings, Stuart (as "Madison") published twelve long letters on the "American Question" in the Richmond Whig and Public Advertiser and later as a combined pamphlet. Neither endorsing nor opposing slavery, Stuart praised American Party's proposals to deny some immigrants rights accorded native-born Americans.