Minneapolis (AP) — The Trump administration has issued a sweeping order that could allow the arrest of tens of thousands of refugees who are lawfully in the United States but have not yet reached permanent residency, according to a Department of Homeland Security memo filed ahead of a Thursday federal court hearing in Minnesota.

The memo, filed in connection with the case before U.S. District Judge John Tunheim, says refugees applying for green cards must return to federal custody one year after they were admitted to the country for review of their applications. The memo said DHS “may maintain custody for the duration of the inspection and examination process,” according to the filing.

The new order arrives hours before Tunheim weighed arguments on whether he should extend a temporary order that protects Minnesota refugees from being arrested and deported. Tunheim said he would issue a written decision on whether the temporary protections would be extended after Thursday’s hearing, and he did not rule immediately.

The possible reach of the policy beyond Minnesota was a focus of the hearing. How many people could be arrested under the new order was unclear. At the same time, Justice Department attorney Brantley Mayers told the court that the government should have the right to arrest refugees one year after entering the country, but he indicated it would not always happen, describing it as a discretion call for DHS to make—an assertion that attorneys for the Minnesota refugees met with skepticism.

After the hearing, Democratic U.S. Sen. Tina Smith said the government “failed to offer any coherent argument for their policy in either law or fact,” adding that she was not present in court but had been briefed. Smith said she and other advocates would “continue the fight for justice in the courts,” flanked by attorneys and refugee rights supporters including U.S. Rep. Ilhan Omar.

Advocacy groups moved quickly to criticize the new policy. HIAS, an international Jewish nonprofit that serves refugees and asylum-seekers, called it “a transparent effort to detain and potentially deport thousands of people who are legally present in this country, people the U.S. government itself welcomed.” HIAS CEO Beth Oppenheim said in a statement that refugees were “promised safety and the chance to rebuild their lives,” but that DHS was “now threatening them with arrest and indefinite detention.”

The dispute in Minnesota centers on a temporary restraining order and a pending question of whether a longer injunction should be granted. Tunheim blocked the government from targeting Minnesota refugees last month, saying the plaintiffs were likely to prevail on their claims that their arrest and detention, and the policy meant to justify them, are unlawful. Tunheim’s Jan. 28 temporary order was set to expire Feb. 25 unless he grants a more permanent preliminary injunction.

In deciding the previous request for relief, Tunheim rejected the government’s argument that it had a legal right to arrest and detain refugees who have not obtained green cards within a year of arriving in the U.S. The judge wrote that mandating detention would lead to an “illogical result,” because refugees cannot apply for green cards until they have been in the country for a year. He also said the government’s interpretation would mean nearly all refugees would face detention unless immigration officials conducted their review at exactly the one-year mark, which he called “nonsensical.”

Tunheim’s earlier decision referenced Operation PARRIS, which the lawsuit says involved an effort to reexamine the cases of 5,600 Minnesota refugees who had not yet been granted permanent resident status. The suit says ICE officers went door to door under the operation, arresting refugees and sending them to detention centers in Texas without access to attorneys, with some later released and left to find their own way back to Minnesota.

The judge noted in his order that refugees are extensively vetted by multiple agencies before being resettled. He wrote that none of the refugees arrested in Operation PARRIS had been deemed a danger to the community or a flight risk, and none had been charged with crimes that could be grounds for deportation. Tunheim also emphasized that refugees are admitted due to persecution in their home countries, and he prohibited further arrests under Operation PARRIS while ordering that detainees still in custody be released and returned to Minnesota.

“They are not committing crimes on our streets, nor did they illegally cross the border. Refugees have a legal right to be in the United States, a right to work, a right to live peacefully,” Tunheim wrote in his order.