John Quincy Adams (/ˈkwɪnzi/; July 11, 1767 – February 23, 1848) was an American statesman who served as the sixth President of the United States from 1825 to 1829. He also served as a diplomat, a Senator and member of the House of Representatives. He was a member of the Federalist, Democratic-Republican, National Republican, and later Anti-Masonic and Whig parties. In his biography, Samuel Flagg Bemis argues that Adams was able to "gather together, formulate, and practice the fundamentals of American foreign-policy – self-determination, independence, noncolonization, nonintervention, nonentanglement in European politics, Freedom of the Seas, [and] freedom of commerce." John Quincy Adams was the son of President John Adams and Abigail Adams. As a diplomat, Adams played an important role in negotiating key treaties, most notably the Treaty of Ghent, which ended the War of 1812. As Secretary of State, he negotiated with Britain over the United States' northern border with Canada, negotiated with Spain the annexation of Florida, and drafted the Monroe Doctrine. Historians agree he was one of the greatest diplomats and secretaries of state in American history. Adams was elected president in a close and controversial four-way contest in 1824. As president he sought to modernize the American economy and promote education. Adams enacted a part of his agenda and paid off much of the national debt. However he was stymied time and again by a Congress controlled by his enemies, and his lack of patronage networks helped politicians eager to undercut him. He lost his 1828 bid for re-election to Andrew Jackson. Adams is best known as a diplomat who shaped U.S. foreign policy in line with his ardently nationalist commitment to U.S. republican values. More recently, he has been portrayed as the exemplar and moral leader in an era of modernization. During Adams' lifetime, technological innovations and new means of communication spread messages of religious revival, social reform, and party politics. Goods, money, and people traveled more rapidly and efficiently than ever before. Adams was elected as U.S. Representative from Massachusetts after leaving office, serving for the last 17 years of his life with far greater acclaim than he had achieved as president. Animated by his growing revulsion against slavery, Adams became a leading opponent of the Slave Power. He predicted that if a civil war were to break out, the president could abolish slavery by using his war powers. Adams also predicted the Union's dissolution over the slavery issue, but said that if the South became independent there would be a series of bloody slave revolts.