WASHINGTON — President Trump’s accounting firm must turn over his financial records to Congress, a Federal District Court judge ruled on Monday, rejecting his legal team’s argument that lawmakers had no legitimate power to subpoena the files.

But Mr. Trump vowed that his legal team would appeal rather than permit the firm, Mazars USA, to comply with the subpoena and the ruling, so the legal fight is far from over.

The ruling by the judge, Amit P. Mehta of the United States District Court for the District of Columbia, was an early judicial test of the president’s vow to systematically stonewall “all” subpoenas by House Democrats, stymieing their ability to perform oversight of Mr. Trump and the executive branch after winning control of the chamber in last year’s midterm elections.

[Read the ruling.]

Mr. Trump’s legal team, led by William S. Consovoy, had argued that the House Committee on Oversight and Reform had no legitimate legislative purpose in seeking Mr. Trump’s financial records and was just trying to dig up dirt — like finding out whether the president broke any laws — for political reasons, so the subpoena exceeded its constitutional authority.