NEW YORK (AP) — A federal judge in New York refused Wednesday to block congressional subpoenas seeking financial records from two banks that did business with President Donald Trump.

U.S. District Judge Edgardo Ramos said in a ruling delivered from the bench that Trump and his company were unlikely to succeed in a lawsuit arguing that the subpoenas seeking records from Deutsche Bank and Capital One were unlawful and unconstitutional.

Ramos also concluded that the subpoenas have "a legitimate legislative purpose."

The lawyers for the House Financial Services and Intelligence committees say they need access to documents from the banks to investigate possible "foreign influence in the U.S. political process."

Deutsche Bank has lent Trump's real estate company millions of dollars over the years.

The hearing falls two days after a federal judge in Washington ruled against Trump in a similar case, finding that the president cannot block a House subpoena for information from a financial services firm that had done accounting work for him and the Trump Organization.

And it comes a day after Trump blocked his former White House lawyer, Don McGahn, from testifying before the House Judiciary Committee.

In a written submission prior to Wednesday's hearing, lawyers for two congressional committees wrote that Trump's effort to block the subpoenas was "flatly inconsistent with nearly a century of Supreme Court precedent."

The lawyers said the House's Committee on Financial Services and Permanent Select Committee on Intelligence sought the information as it investigates "serious and urgent questions concerning the safety of banking practices, money laundering in the financial sector, foreign influence in the U.S. political process, and the threat of foreign financial leverage, including over the president, his family and his business."

Lawyers for Trump responded in writing that accepting the view of the committees would mean "Congress can issue a subpoena on any matter, at any time, for any reason, to any person, and there is basically nothing a federal court can do about it."

Trump's lawyers had asked the judge to temporarily block Congress from obtaining the records.

The banks took no position in the dispute.

The ruling is the second blow in New York on Wednesday to the privacy of Trump’s financial details. State lawmakers earlier passed a measure that would allow the president’s tax returns to be released to congressional committees.