John Adams was in the final weeks of his presidency when Chief Justice Oliver Ellsworth announced he was retiring from the Supreme Court for health reasons.

It was December 1800. Adams had just lost a bitterly contested presidential election to his fellow Founder Thomas Jefferson. Jefferson was Adams’s vice president, but the two men were rivals with entirely different political views.

Federalists urged the president to find a replacement before Jefferson took office on March 4, 1801.

In late January of 1801, Adams filled the vacancy by appointing Secretary of State John Marshall as the new chief justice.

President-elect Jefferson, who despised Marshall, was furious. To open a seat on the high court, Jefferson soon pushed for the impeachment of Justice Samuel Chase, whom he also wasn’t crazy about.

More than two centuries later, the nation is consumed by another fight over the high court as President Trump rushes to fill the seat of Justice Ruth Bader Ginsburg, who died last week at 87. Democrats argue the Supreme Court choice should be left up to the president who is elected Nov. 3, but are powerless to stop the Republican-controlled Senate from confirming Trump’s nominee.

Adams had just moved into the newly completed White House, then known as the President’s House, when Ellsworth announced his retirement.

After considering several candidates to replace him, Adams met in January of 1801 with Marshall to discuss possible choices. Suddenly, Adams declared, “I believe I must nominate you.”

Marshall later said he was “pleased as well as surprised,” and that he “bowed in silence” as he left. The Federalist-controlled Senate confirmed Marshall a week later.

The Federalists also voted to reduce the number of Supreme Court seats to five from six when the next vacancy occurred so Jefferson couldn’t appoint anyone. They pushed through the Judiciary Act of 1801 to add 16 circuit court judges and other judicial appointees, all with lifetime terms. The action was “conceived either in folly or in petulance and malice,” one Philadelphia newspaper said.

Adams had 19 days to appoint and commission the new judges. Marshall, who was still the acting secretary of state, was reportedly signing judicial commissions in his office at midnight before Jefferson’s inauguration the next day. Jefferson’s designated attorney general burst into the room and declared that the new president had ordered him “to take possession of this office and its papers.”

Some historians doubt the story is true, but the Adams appointees did become known as the “midnight judges.”

Jefferson charged that the judiciary act was “a parasitical plant engrafted” on the “judicial body” as a last-ditch effort to thwart him. But, he wrote to James Madison, “It is difficult to undo what is done.”

As for the Supreme Court appointment, there wasn’t any love lost between Marshall and Jefferson, even though they were cousins. Marshall, who had fought in the Revolutionary War, believed Jefferson had dodged military combat. Jefferson’s political views also made him “unfit” for the presidency, Marshall wrote Alexander Hamilton in early 1801.

Jefferson charged that Marshall’s staunch Federalist views were anti-democratic. In a letter to Madison, Jefferson complained about Marshall’s “profound hypocrisy.” But there was nothing he could do about the chief justice, who had a lifetime appointment. He still had Marshall swear him in as president.

After Jefferson’s Democratic-Republicans took control of Congress, they wasted little time in undoing some of Adams’s actions. They passed the Judiciary Act of 1802, which repealed the Judiciary Act of 1801, eliminating the new judges. Then Jefferson saw an opportunity to grab a seat on the Supreme Court.

In 1803, Chase, while presiding over a circuit court case in Baltimore, blasted Jefferson’s party for repealing the 1801 judiciary law. He told a grand jury that America risked sinking into a “mobocracy, the worst form of all government.”

Jefferson and others considered the ill-tempered Chase, who was a signer of the Declaration of Independence, to be a dictatorial jurist who blatantly inserted his Federalist politics into his decisions. Jefferson wrote to a lawmaker, “Ought the seditious and official attack on the principles of our Constitution … to go unpunished?”

Virginia Rep. John Randolph led impeachment charges against Chase in early 1804, declaring he would wipe the floor with the obnoxious justice. In March of 1804, the House impeached Chase on charges of “arbitrary, oppressive and unjust” conduct.

The Senate trial began that November. Presiding was Vice President Aaron Burr, still facing possible murder charges for having recently killed Hamilton in a duel. Though Jefferson’s party held the majority, in early 1805 the Senate acquitted Chase.

Jefferson responded that “Impeachment is a farce which will not be tried again.” Chase is the only justice ever to be impeached.

Meantime, Jefferson won approval to restore the sixth seat to the high court and add a seventh. He ended up appointing three justices by the time he left office in 1809. By then, Marshall had become an imposing legal force.

In 1803, William Marbury, a justice of the peace who had lost his appointment when Congress canceled the new judgeships, petitioned the Supreme Court to force Secretary of State Madison to give him his commission. He didn’t get it. But Marshall used the case to write his landmark Marbury v. Madison opinion that established the principle of judicial review of laws passed by Congress.

Marshall went on to serve 34 years, the longest tenure of any chief justice. He died in 1835 at the age of 79.

Adams once wrote: “The proudest act of my life was the gift of John Marshall to the people of the United States.”

Read more Retropolis: