State and local officials cannot block refugees from being resettled in their jurisdictions, a federal judge ruled Wednesday, finding the Trump administration’s new refu­gee policy is likely to be “unlawful” and “does not appear to serve the overall public interest.”

U.S. District Judge Peter J. Messitte of Maryland temporarily halted President Trump’s executive order requiring governors and local officials nationwide to agree in writing to welcome refugees before resettlements take place in their jurisdictions.

“Giving states and local governments the power to consent to the resettlement of refugees — which is to say veto power to determine whether refugees will be received in their midst — flies in the face of clear Congressional intent,” Messitte wrote in a 31-page decision.

The judge said the administration’s grant of a veto power is “arbitrary and capricious as well as inherently susceptible to hidden bias.”

“One is left to wonder exactly what the rationale is for doing away entirely with a process that has worked so successfully for so long,” he wrote. “And why now?”

The ruling came in response to a lawsuit filed by three refugee resettlement agencies that work with the State Department to welcome into the United States adults and children who fled war and persecution in other countries.

Trump issued the order in September to give locals a voice in the federal resettlement process for the first time and promised to resettle refugees only in areas “that are eager and equipped” to receive them.

But the resettlement agencies argued in court that the consent requirement has caused chaos and confusion and that it threatens to dismantle a support network that connects refugees to housing, jobs and English classes needed to start their new lives in the United States. And critics argued that nothing in Trump’s order prevents refugees from ultimately relocating to states, counties and cities that have said they do not want new refugees.

The resettlement agencies had asked Messitte, a Bill Clinton nominee, to rule swiftly because approval letters are due beginning Jan. 21 if refugees are to start arriving in June. Resettlement workers have been in a “frenzy” seeking approval from state and local governments, the judge wrote, distracting them from their main mission.

Krish O’Mara Vignarajah, the president of the Lutheran Immigration Refugee Service, one of the agencies that filed the lawsuit, said the injunction “provides critical relief.”

“Those who have been waiting for years to reunite with their families and friends will no longer have to choose between their loved ones and the resettlement services that are so critical in their first months as new Americans,” she said.

The Justice Department declined to comment on the ruling, which the government can appeal.

So far, 42 governors and more than 100 local governments have signed letters of acceptance, indicating they would be willing to accept refugees, according to the Lutheran refu­gee agency. Seven states have not said whether they would accept refugees: Georgia, Florida, South Carolina, Alabama, Mississippi, Hawaii and Wyoming.

Texas last week became the first state to publicly refuse to resettle new refugees, with Gov. Greg Abbott (R) saying the state has “carried more than its share.” Texas received more than 2,400 refugees during the past fiscal year, the most of any state.

Abbott’s office did not respond to requests for comments Wednesday after the court ruling.

Trump issued the order after he set the annual national refugee cap for this fiscal year at a historic low of 18,000, down from 110,000 in 2016.

Trump administration lawyers defended the policy, calling it a “common-sense requirement” that encourages local input.

Justice Department lawyer Bradley Humphreys said Trump’s order does not give local officials “veto” power because the U.S. secretary of state can overrule their decisions.

Resettlement groups said the rule could prevent refugees from being reunited with U.S.-based friends and relatives who can support them.

Kathleen Jones, the vice chair of the Burleigh County commission in North Dakota, which voted narrowly in December to accept refugees, cheered the ruling.

“In one word, it’s ‘Hallelujah,’ ” Jones said. “I really feel that the Trump administration had no business sticking their nose into this.”

But Brian Bitner, another Burleigh County commissioner, said he was disappointed that the ruling stripped locals of their newfound influence over refugee resettlement. Burleigh County had debated the issue publicly for hours and probably would have debated it again next year, as Trump’s order requires annual consideration of refu­gee resettlement.

“I would feel disappointed if we went through all this trouble, time, and effort for nothing,” said Bitner, who voted against resettling refugees because of questions about the cost.