John Adams faced many difficulties as president, including divisions between his Federalist party and the opposing Republican party of Thomas Jefferson. He had to deal with tensions with France during the XYZ Affair, which led to an undeclared naval war. Adams also signed controversial laws known as the Alien and Sedition Acts. He lost reelection in 1800 to Jefferson due to several factors, including the unpopularity of the Acts. Before leaving office, Adams appointed several "Midnight Judges" to help ensure future Federalist control of the courts.