By Joseph De Avila

A federal judge has permanently blocked the Trump administration from withholding funds from a $16 billion rail tunnel project that would connect New York and New Jersey under the Hudson River.

U.S. District Judge Jeannette Vargas, appointed by former President Joe Biden, on Monday ruled in favor of the two states. The states sued in February, arguing the Trump administration's freeze was politically motivated and arbitrary and capricious.

The White House referred requests for comment to the Transportation Department. The Transportation Department remains "committed to ensuring hardworking taxpayer dollars are being spent responsibly," an agency spokesperson said. The Trump administration said last year it wouldn't distribute the funds while it reviewed whether the project included any diversity, equity and inclusion policies.

"President Donald J. Trump, however, made contemporaneous statements indicating that he had personally made the decision to 'terminate' funding for the Project," Vargas wrote.

Vargas's opinion included public comments Trump made in October, in which the president stated "It's terminated because the Democrats are so foolish."

"Right now, there is no funding — because it's up to me," Trump continued.

The project manager overseeing the rail tunnel construction said in January it would be forced to cancel work on the project without the funds. About $12 billion in funding for the project comes in the form of federal grants, while $4 billion comes from federal loans to be repaid by New York and New Jersey and by the Port Authority of New York and New Jersey.

After New York and New Jersey sued, Vargas temporarily blocked the Trump administration from freezing the funds while the case proceeded. Monday's ruling permanently bars the Trump administration from withholding the money.

In her opinion, Vargas said the Trump administration failed to show the suspension of the funds was lawful.

"Defendants make no attempt to justify their actions as consistent with the governing federal regulations," Vargas said.

Write to Joseph De Avila at joseph.deavila@wsj.com