A federal judge in Boston is considering whether to temporarily ban the Trump administration from targeting funding for Chelsea and Somerville over their refusal to participate in most federal immigration enforcement practices.

Attorneys with Lawyers for Civil Rights, the organization representing the cities, asked Judge Nathan Gorton at a hearing on Thursday to stop the Trump administration from withholding millions of dollars in federal funding as their lawsuit plays out.

Chelsea and Somerville, which have long had sanctuary city ordinances, argue that President Trump’s executive orders and directives to withhold funding from them is unconstitutional.

“What we are concerned about is the campaign of coercion that is happening right now, that there will be cities that will not be able to withstand the pressure of the federal government and will give up their rights because they feel that they have no choice,” said Oren Sellstrom, litigation director for Lawyers for Civil Rights, after the hearing. “That is what we want to prevent for Somerville and for Chelsea.”

Gorton took the matter under advisement following oral arguments.

Sellstrom argued that the handful of executive orders issued by the Trump administration create uncertainty around funding for local programs on a wide range of matters, including education, law enforcement and transit, and it disrupts the ability of local officials to budget for residents’ needs.

Gorton asked Elisabeth Neylan, the attorney for the Department of Justice, to support the government’s argument that executive directives are insulated from legal challenges if other courts haven’t supported that.

So far, the plaintiffs have pointed to only a single grant of $4 million for road safety improvements in Somerville that has been cancelled, but said other funding could be on the chopping block too.

Neylan said federal agencies like the U.S. Department of Transportation have “broad authority” to decide who is eligible for grant funding, and that the transportation secretary is empowered to do so.

“In his determination, jurisdictions that issue driver’s licenses to illegal aliens and otherwise impede the enforcement of federal immigration law undermine the safety and security of the transportation system the agency supports,” she said.

Neylan argued that the lack of canceled grants meant that the directives were not “final actions,” and that plaintiffs hadn’t demonstrated significant harms, so an injunction shouldn’t move forward.

Gorton asked Sellstrom to outlined the “kind of irreparable harm” that plaintiffs would suffer if he doesn’t issue a preliminary injunction.

Sellstrom said that cities must look to the future when budgeting and that the potential to lose future money because of conditions qualified as a harm.

“It’s the idea that this sword of Damocles is hanging over the city’s head,” he told the judge.

Plaintiffs argue that the administration’s policies run afoul of the Constitution in several ways, including violating the separation of powers, the Constitution’s spending clause, the Tenth Amendment, and the due process and vagueness clauses of the Fifth Amendment. They also allege violations of the Administrative Procedure Act.

They are particularly focused on the Tenth Amendment, which says the federal government can’t compel state or local governments to enact or enforce federal regulatory programs.

“I’m here today because the federal administration wants to coerce us into using our local police in mass deportation plans, instead of allowing them to do local policing for which they have been trained,” said Somerville Mayor Katjana Ballantyne outside of the courthouse.

In fiscal year 2024, Somerville received $19.4 million in federal funds for food pantry operations, emergency shelter during extreme weather, and roadway safety programs, according to the suit.

Chelsea received about $14.5 million in the same time period for education, infrastructure improvement programs, and law enforcement purposes.

The lawsuit cites that about $8.5 million in Chelsea’s 2025 city budget is at stake, specifically for the police department, schools, and meals for seniors. Three police officer positions are on the line due to them being tied to grant funding.

Chelsea City manager Fidel Maltez described the people of his community as “the underdogs.”

“We are here because our federal funding, which is critical to the health and well-being of all of our residents, is being unlawfully held hostage,” he said.

Both cities long ago adopted sanctuary policies in which local police are limited in how and when they can assist with federal immigration enforcement. City officials identified trust of law enforcement as reasons to keep these policies — saying that without them, their heavily immigrant populations would be afraid to report crimes or cooperate with local police due to fear of potential deportation.

About 45% of Chelsea’s resident’s are foreign born, and 65% are Latino, according to U.S. Census figures. For Somerville, it’s about 24%.