A Manhattan federal judge ordered the Trump administration to unfreeze funding for the sprawling Gateway project on Friday, paving the way for work to resume on a new set of Hudson River tunnels.

Judge Jeannette Vargas’ order came in a lawsuit filed by the New York and New Jersey attorneys general against the federal government. The states argued the White House’s order to withhold the funds was illegal and caused economic harm.

“Plaintiffs have adequately shown that the public interest would be harmed by a delay in a critical infrastructure project,” Vargas wrote, barring the federal government from suspending funding while the case proceeds.

New Jersey lawyer Shankar Duraiswamy said in oral arguments before the ruling that pausing the project would cause “irreparable harm.” If the disruption were to drag on, he said, it could “torpedo the project.”

The federal government argued the case should not be heard in Manhattan, and instead belonged in a federal claims court in Washington, D.C.

Gateway officials have filed a lawsuit there as well. A hearing in that case is scheduled for Tuesday.

The $16 billion Gateway project is one of the largest public works projects in the country. More than 1,000 jobs were put on hold by Trump’s funding freeze, which comes amid a dispute with Democrats over ICE’s harsh immigration crackdown.

“This ruling is a victory for the thousands of union workers who will build Gateway and the hundreds of thousands of riders who rely on it every day. We will work to protect this decision and move as soon as possible to get work back on track,” Gov. Kathy Hochul said in a statement.

On Friday it emerged that the White House had floated unlocking the Gateway in exchange for Democrats’ support of renaming Penn Station and Washington Dulles International Airport after Trump.

The Gateway commission managing the mammoth project said in court filings that winding down operations at five construction sites was a huge undertaking in itself. It would take nearly a year of work and $15 million to $20 million a month to secure and monitor the work sites, as well as store the expensive equipment, like the boring machine that cost nearly $500 million.

Gateway announced the work was officially paused Friday morning because it had exhausted a line of credit. The new tubes would serve NJ Transit and Amtrak trains heading to and from Penn Station. Gateway officials say they must be built in order to close and repair the old tubes, which were damaged in 2012 by Hurricane Sandy.

“This is a critical victory for workers and commuters in New York and New Jersey. I am grateful the court acted quickly to block this senseless funding freeze, which threatened to derail a project our entire region depends on,” New York Attorney General Letitia James said.