The presidency of Thomas Jefferson began on March 4, 1801, when he was inaugurated as the third President of the United States, and ended on March 4, 1809. Jefferson assumed the office after defeating incumbent President John Adams in the 1800 presidential election. Jefferson assumed the office after defeating incumbent President John Adams in the 1800 presidential election. The election was a realigning election in which the Democratic-Republican Party swept the Federalist Party out of power, ushering in a generation of Democratic-Republican dominance in American politics. After serving two terms, Jefferson was succeeded by Secretary of State James Madison, also of the Democratic-Republican Party. He established a military academy, used the Navy to protect merchant ships from Barbary pirates in North Africa, and developed a plan to protect U.S. ports from foreign invasion by the use of small gunboats (a plan that proved useless when war came in 1812). He also authorized the Lewis and Clark expedition to explore the Louisiana Territory and the Pacific Northwest.