WASHINGTON — President Trump on Monday lost an early round of his court fight with Democrats when a federal judge ruled that the president’s accounting firm must turn over his financial records to Congress as lawmakers seek to assert their oversight authority.

Trump called the 41-page ruling from U.S. District Judge Amit Mehta of Washington “crazy,” and he said he would appeal, adding: “We think it’s totally the wrong decision by obviously an Obama-appointed judge.”

Lawyers for the president are fighting document and witness subpoenas on several fronts, and Mehta’s ruling came hours after former White House counsel Donald McGahn was directed not to appear before a congressional committee seeking testimony about his conversations with Trump.

Congressional Democrats have vowed to fight for evidence of potential misconduct by Trump and those close to him, and the president’s legal team is broadly resisting those efforts. How those fights play out in court in the months ahead could affect the 2020 presidential race.

In his decision, Mehta flatly rejected arguments from the president’s lawyers that the House Oversight Committee’s demands for the records from Trump’s accounting firm, Mazars USA, were overly broad and served no legitimate legislative function.

“It is simply not fathomable,” the judge wrote, “that a Constitution that grants Congress the power to remove a President for reasons including criminal behavior would deny Congress the power to investigate him for unlawful conduct – past or present – even without formally opening an impeachment inquiry.”

Trump has argued those congressional inquiries are politically motivated attacks on the authority of the presidency, while Democrats insist that the subpoenas are essential to ensuring that no president is above the law.

When the lawsuit was filed, Trump’s private attorney Jay Sekulow said in a statement that the president’s team “will not allow Congressional Presidential harassment to go unanswered.”

The company said in a statement that it will “respect the legal process and fully comply with its legal obligations.”

While Democrats scored the first court victory in the fight over the president’s financial records, it’s unclear how many of these disputes will reach higher courts, or how those courts might rule.

Rep. Elijah Cummings, D-Md., chairman of the House committee, said the ruling “lets America know that we have ground to stand on and that we have a legitimate argument and the courts support them. … I’m glad it was a strong decision, that bodes well hopefully in the future for an appeals process.”

Monday’s ruling threw historical shade at Trump, comparing him with former President James Buchanan, generally considered one of the country’s worst leaders, who had also complained bitterly about “harrassing” congressional inquiries.

Mehta noted that Congress also launched an investigation into the conduct of Bill Clinton before he became president.

“Congress plainly views itself as having sweeping authority to investigate illegal conduct of a President, before and after taking office,” the judge wrote. “This court is not prepared to roll back the tide of history.”

The judge gave the White House a week to formally appeal the decision, adding that “the President is subject to the same legal standard as any other litigant that does not prevail.”

An appeal could test decades of legal precedent that has upheld Congress’ right to investigate – a legal battle that is one part of a broader effort by House Democrats to examine Trump’s finances, his campaign and allegations that he sought to obstruct justice in special counsel Robert Mueller’s Russia investigation.

In the Mazars case, Mehta cut down Trump lawyers’ complaint that Congress was usurping the Justice Department’s powers to investigate “dubious and partisan” allegations of private conduct, by inquiring into whether Trump misled his lenders by inflating his net worth.

Rather, Mehta said, a congressional investigation into illegal conduct before and during a president’s time in office fits “comfortably”with Congress’ broad investigative powers, which include an “informing function,” or power to expose corruption.

Trump, his three eldest children and companies also are attempting to block a subpoena by the House Financial Services Committee for Trump’s bank records issued to Deutsche Bank and Capital One Financial, which a federal judge in Manhattan is set to hear Wednesday.

The pace of the president’s legal fights with Congress is picking up.

House Intelligence Committee chairman Rep. Adam Schiff, D-Calif., said Monday that his panel will vote Wednesday to enforce its subpoena for the redacted portions of the Mueller report, along with certain underlying materials.

Schiff accused the Justice Department of granting Republican lawmakers’ document requests and denying demands from Democrats.

“The refusal by the department, if it persists, will be a graphic illustration of bad faith and a unwillingness to cooperate with lawful process,” Schiff said.

On Monday, the Justice Department issued a formal legal opinion saying that McGahn, the former top White House lawyer, could not be required to appear in response to a congressional subpoena.

Democrats had subpoenaed McGahn to testify Tuesday morning, hoping he would become a star witness in their investigation into whether Trump obstructed justice. McGahn provided critical testimony in several instances of potential obstruction by Trump, detailed in Mueller’s report.

“The Department of Justice has provided a legal opinion stating that, based on long-standing, bipartisan, and constitutional precedent, the former counsel to the president cannot be forced to give such testimony, and Mr. McGahn has been directed to act accordingly,” White House press secretary Sarah Sanders said in a statement. “This action has been taken in order to ensure that future presidents can effectively execute the responsibilities of the office of the presidency.”

The 15-page legal opinion written by Assistant Attorney General Steven Engel argues that McGahn cannot be compelled to testify before the committee, based on past Justice Department legal memos regarding the president’s close advisers.

The memo says McGahn’s immunity from congressional testimony is separate and broader than a claim of executive privilege.

The immunity “extends beyond answers to particular questions, precluding Congress from compelling even the appearance of a senior presidential adviser – as a function of the independence and autonomy of the president himself,” Engel wrote.

Trump told reporters the action was taken “for the office of the presidency, for future presidents. I think it’s a very important precedent. And the attorneys say that they’re not doing that for me, they’re doing it for the office of the president.”

Those comments underscore the high stakes of Trump’s current standoff with Congress – if either side loses a legal ruling by an appeals court, or the Supreme Court, the reverberations could be felt far beyond the Trump administration, changing the balance of power between the executive and the legislative branches of government for years to come.

In the fight over McGahn’s testimony, the Justice Department insists that immunity from testimony does not evaporate once a presidential adviser leaves the government, because the topics of interest to Congress are discussions that occurred when the person worked for the president.

As a private citizen, McGahn is not necessarily bound by the White House directive, or the Justice Department memo, to refuse to comply with the subpoena. There was no immediate word from McGahn’s lawyer on whether he would defy the White House.

The move to bar McGahn from answering lawmakers’ questions angered House Democrats already eager to hit back at what they view as White House stonewalling. The defiance raises the possibility that the House will hold McGahn in contempt of Congress, as House Judiciary Committee Chairman Jerrold Nadler, D-N.Y., has threatened.

“It is absurd for President Trump to claim privilege as to this witness’s testimony when that testimony was already described publicly in the Mueller report,” Nadler said in a statement. “Even more ridiculous is the extension of the privilege to cover events before and after Mr. McGahn’s service in the White House.”

Several Democrats also want to begin impeachment proceedings against Trump, even though House Speaker Nancy Pelosi, D-Calif., last week privately downplayed the possibility and encouraged her members to focus on their policy agenda.

Some Democrats believe opening an impeachment inquiry will strengthen their hand in trying to force the White House to comply with document requests and witness testimony, including McGahn’s.

House Democrats were hoping to make McGahn their key witness as they seek to unpack the findings of the Mueller report – particularly regarding questions of whether Trump obstructed justice.