U.S. District Judge Trevor McFadden said efforts by Trump's lawyers to block the handover were wrong on the law.
"A long line of Supreme Court cases requires great deference to facially valid congressional inquiries. Even the special solicitude accorded former presidents does not alter the outcome," McFadden wrote.
McFadden put the ruling on hold for 14 days to give Trump's legal team time to appeal.
A spokesperson for Trump did not immediately respond to a request for comment.
House Ways and Means Committee Chairman Richard Neal, D-Mass., first asked for the tax information in April 2019, citing a federal law that requires the Treasury Department and the IRS to turn over individual tax returns when demanded by any of the three congressional tax committees.
The Treasury Department refused to provide the documents at the time, with the administration arguing that Congress had no legitimate lawmaking purpose to seek them and that it was simply hoping to find something that would embarrass Trump.
Neal renewed the request this year, saying the Ways and Means Committee wanted the information to see how well the IRS was carrying out its policy of automatically auditing every president's tax returns. This time, the Treasury Department, backed by a Justice Department legal position, said Trump's returns should be handed over to Congress.
That led to the current lawsuit.
McFadden on Tuesday rejected Trump's claim that Congress had no legitimate need to see the returns and was simply hoping to find something embarrassing.
"Congress may not expose someone simply for the sake of exposure," McFadden said. But he wrote that the committee's desire to see how the IRS audits presidential returns could lead Congress to conclude that the authority needed to be enhanced.
Despite obviously political comments by other members of Congress, including House Speaker Nancy Pelosi, D-Calif., about a general desire to see Trump's taxes, "the committee need only state a valid legislative purpose," McFadden said, adding, "It has done so."
McFadden, who was appointed to the bench by Trump, concluded by saying Congress can accomplish its objectives without making the returns public.
"It might not be right or wise to publish the returns, but it is the chairman's right to do so," wrote McFadden, who also warned that "publishing the confidential tax information of a political rival is the type of move that will return to plague the inventor."