President Donald Trump is feeling the heat. In a surprise Rose Garden speech on Wednesday, Trump railed against congressional investigations and ongoing efforts by Democrats to examine potential misconduct by the president, his family and his associates. "I respect the courts, I respect Congress, but what they've done is abuse," the president told the press, before going on to say he would refuse to work with Congress until the investigations were concluded.

Although it's useless to speculate about what motivates this particular chief executive, it seems likely that his outburst was influenced by several recent political setbacks. The first was House Speaker Nancy Pelosi saying Trump engaged in a "cover-up." The second was an important legal decision that has clear implications for numerous legal showdowns expected between the executive branch and the legislative branch.

Although it's useless to speculate about what motivates this particular chief executive, it seems likely that his outburst was influenced by several recent political setbacks.

On Monday, U.S. District Court Judge Amit P. Mehta ruled in favor of the legislative branch, reaffirming the importance of congressional oversight authority. The judge’s decision previews what Trump can expect going forward as he tries to use the justice system as his personal shield from Congress.

At issue in this case was an accounting firm responsible for preparing Trump’s tax returns. The House Committee on Oversight and Reform subpoenaed financial documents from the firm, Mazars USA, which could show Trump manipulated his earnings among other things. Trump filed a lawsuit against the committee and its chairman, Rep. Elijah Cummings, D-Md., in April, hoping to block the committee’s subpoena.

Mehta’s 41-page decision is a pointed defense of Congress’ oversight power, power that Trump and his administration have resisted at every possible turn. Trump and his legal team should be concerned with how thoroughly Mehta deconstructed the president’s case for ignoring Congress.

“A congressional investigation to carry out an expressly delegated Article I function, in addition to any legislation that might be had relating to that function, is plainly valid. So, too, is an investigation to determine whether the President has any conflicts of interest. As already discussed, it lies within Congress’s province to legislate regarding the ethics of government officials,” Mehta wrote in his decision.

The crux of Trump’s efforts to block cooperation with congressional subpoenas hinges on the argument that “there is no possible legislation at the end of this tunnel.” The president believes that absent a specific legislative purpose, Congress cannot investigate matters like his financial records.

But Mehta addressed this argument directly: “Obtaining records to shed light on whether the President has undisclosed conflicts of interests is therefore entirely consistent with potential legislation in an area where Congress already has acted and made policy judgments.”

This feels like one of the more important lines from Mehta, especially regarding the question of legislative relevance: “The critical inquiry then is not legislative certainty, but legislative potential.” Simply put, congressional investigations do not have to be fixed to a specific policy proposal or action.

But neither does Congress need to formally open an impeachment inquiry to investigate the president’s potentially illegal behavior, according to Mehta. This is important because Democrats have not arrived at a consensus when it comes to impeachment, although a growing number of House Democrats do seem at least seem open to the idea. “There’s a growing understanding that the impeachment process is inevitable — when, not if,” House Budget Committee Chairman John Yarmuth, D-Ky., said Tuesday.

“It is simply not fathomable 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,” Mehta wrote. “Congress plainly views itself as having sweeping authority to investigate illegal conduct of a President, before and after taking office. This court is not prepared to roll back the tide of history.”

Writing earlier in May for NBC News THINK, Suzanne Garment argued that “the laws governing this executive-legislative dispute aren’t black-and-white — which means that the other side is always going to have a plausible argument to present to a court, which, in turn, means that no magic legal slam dunks are available.”

It's certainly true that there are no slam dunks here, especially with the current Supreme Court, but Mehta’s decision suggests Trump’s strategy to try and effectively run out the clock on congressional Democrats may have some holes in it. Former House Judiciary Committee general counsel Ron Klain put it best tweeting: “Many pundits have been saying that if the House Dems fight Trump in court, Trump will simply be able to run out the clock. This ruling shows that the courts can act quickly, and are likely to do so.”

The president is hoping the path through the judicial branch will be time-consuming and opaque. But in this case, as Klain noted, it was expeditious and definitive. Trump is also hoping a judge will be willing to undo judicial precedent that has protected our system of checks and balances since the formation of our nation. But clearly, there are judges who disagree.

Every time the president loses a case in a court of law, his alleged lawlessness becomes clearer. This could hurt him politically, but just as important it affect his brand. For someone as fixated on “winners” and “losers” as Trump is, it’s unlikely that he’s going to take losing in the courtroom very well. And of course, each decision provides fresh ammunition for congressional Democrats looking to weaponize the president’s bad behavior ahead of the 2020 election.

President Trump is already at war with one branch of government; he may not be able to sustain a fight against two of them.