In the U.S. House of Representatives (1789-97), Madison helped frame and ensure passage of the Bill of Rights. He also assisted in organizing the executive department and creating a system of federal taxation. As leaders of the opposition to Hamilton's policies, he and Jefferson founded the Democratic-Republican Party.
In 1794 Madison married a vivacious widow who was 16 years his junior, Dolley Payne Todd, who had a son; they were to raise no children of their own. Madison spent the period 1797-1801 in semiretirement, but in 1798 he wrote the Virginia Resolutions, which attacked the Alien and Sedition Acts. While he served as Secretary of State (1801-9), his wife often served as President Jefferson's hostess.
In 1809 Madison succeeded Jefferson. Like the first three Presidents, Madison was enmeshed in the ramifications of European wars. Diplomacy had failed to prevent the seizure of U.S. ships, goods, and men on the high seas, and a depression wracked the country. Madison continued to apply diplomatic techniques and economic sanctions, eventually effective to some degree against France. But continued British interference with shipping, as well as other grievances, led to the War of 1812.
The war, for which the young nation was ill prepared, ended in stalemate in December 1814 when the inconclusive Treaty of Ghent which nearly restored prewar conditions, was signed. But, thanks mainly to Andrew Jackson's spectacular victory at the Battle of New Orleans (Chalmette) in January 1815, most Americans believed they had won. Twice tested, independence had survived, and an ebullient nationalism marked Madison's last years in office, during which period the Democratic-Republicans held virtually uncontested sway.