A federal judge dealt a blow to President Donald Trump on Wednesday, ruling that two banks can hand over his financial documents in response to congressional subpoenas.

The Trump family and company sued Deutsche Bank and Capital One last month in an effort to block them from turning over financial documents sought by Congress. The House Intelligence and Financial Services committees had issued subpoenas to several banks as part of their investigations of alleged foreign influence on U.S. elections.

In his ruling, U.S. District Judge Edgardo Ramos said he disagrees with the arguments from the Trump family attorneys that the subpoenas don't have a legitimate legislative purpose.

Ramos described the subpoenas as "undeniably broad" but "clearly pertinent."

Ramos issued his ruling after hearing arguments from lawyers representing the Trump and the Democratic-controlled congressional committees.

The Trump family lawyers signaled that they will appeal the ruling, but they did not comment after the hearing.

Deutsche Bank has lent Trump's real estate company millions of dollars over the years. Capitol One is among the banks that houses Trump's personal accounts.

In a statement released after the ruling, Deutsche Bank said it won't fight the judge's order.

"We remain committed to providing appropriate information to all authorized investigations and will abide by a court order regarding such investigations," the statement read.

Capital One did not immediately return a request for comment.

In a statement to NBC News, House Financial Services Chairwoman Maxine Waters said she was "very pleased" with the judge's ruling.

"We believe that we're on the right track and that no matter what this President is doing to try and impede our ability to have access to information, we're going to keep going and we're going to fight and we're going to get good victories that way," added Waters, D-Calif.

Trump wrote a $35,000 check to his former personal attorney Michael Cohen from his Capital One checking account in August 2017. The money was tied to the effort to pay off porn star Stormy Daniels, who alleged that she had an affair with Trump before he took office.

Cohen submitted the check to Congress ahead of his testimony in March.

In the lawsuit, Trump's attorneys argued that the subpoenas were politically motivated and unwarranted.

“The subpoenas were issued to harass President Donald J. Trump; to rummage through every aspect of his personal finances, his businesses and the private information of the president and his family; and to ferret about for any material that might be used to cause him political damage,” said the suit, filed on behalf of Trump, his company and three eldest children — Donald Jr., Eric and Ivanka.