After losing the senate election in 1808, he served as United States Minister to Russia from 1809 to 1814 under Madison administration, and United States Minister to United Kingdom from 1815 to 1817 under Madison and Monroe Administration. He duly reported on Napoleon's failed invasion, and among various other events. He headed the Commission that negotiated the Treaty of Ghent in 1814, which ended the War of 1812 with Great Britain. He served as Secretary of State under James Monroe from 1817 to 1825. As Secretary of State, his views about territorial expansion guided President Monroe's policies. His diplomacy with Spain led to the Adams–Onís Treaty of 1819. Monroe Doctrine reflected various of Adam's political views.
Immediately upon becoming Secretary of State, Adams emerged as one of Monroe's most likely successors for presidency. Since the Federalist Party had collapsed, all the major contenders for presidency were from Democratic-Republican party. His initial choice for vice presidential candidate was Andrew Jackson, but as the election approached, Jackson entered the race for president. Adams was nominated by Massachusetts legislature as presidential candidate.
The election of 1824 was the only election in American history in which no presidential candidate received a majority of the votes in the electoral college. Andrew Jackson received 99 electoral votes but was 32 votes short of the amount needed to reach a majority. He won the largest number of popular votes. William H. Crawford received 41 electoral votes, and Henry Clay received 37.
Since no candidate received a clear majority votes in electoral college, the responsibility for electing a new president devolved upon the U.S. House of Representatives, which held a contingent election on February 9, 1825. As prescribed in the 12th Amendment, the top three candidates in electoral college vote would be eligible to receive state delegation votes, and the remaining candidates would be eliminated, accordingly, Henry Clay was eliminated. Henry Clay, the Speaker of the House was highly influential. By contrast, Clay viewed Jackson as a dangerous demagogue, and he was unwilling to support Crawford due to the latter's health issues. Adams and Clay met before the contingent election, and Clay agreed to support Adams in the election. Thus, Adams was elected president on the first ballot.
1825 contingent presidential election vote distribution
The 1828 presidential election was a rematch between incumbent president Adams and Andrew Jackson. Adams had selected Richard Rush as his vice presidential running mate in the Anti-Jacksonian Party ticket. Andrew Jackson was nominated by Jacksonian Party ticket with John C. Calhoun as his running mate. Adams lost to Jackson in a landslide, and was able to win only those states which his father John Adams had won in the 1800 presidential election. Adams did not attend Jackson's inauguration, making him one of only four presidents who finished their terms but chose to skip the event.
Adams contested his first election for House of Representatives in 1802, in which he narrowly lost to William Eustis. After his presidency, he contested the election for House of Representatives from Massachusetts's 11th congressional district. He won the election in a landslide, and wrote in his diary that "my election as President of the United States was not half so gratifying to my inmost soul. No election or appointment conferred upon me ever gave me so much pleasure." He was sworn in on December 5, 1831, and seven days later was appointed chairman of the Committee of Manufactures. He is the only President to be elected in House of Representatives after leaving office. He served nine post-presidential terms in Congress from 1830 until his death in 1848, usually voting in the minority. He supported the rechartering of the Bank of the United States, opposed the annexation of Texas and the war with Mexico.
^"Massachusetts 1808 U.S. Senate". Tufts Digital Collations and Archives. A New Nation Votes: American Election Returns 1787–1825. Tufts University. Archived from the original on December 25, 2019. Retrieved February 3, 2018., citing The Pittsfield Sun (Pittsfield, MA). June 11, 1808.