BOSTON — Cities and towns that refuse to cooperate with federal immigration agents could lose aid from the state under a Republican proposal on Beacon Hill.

A House budget amendment filed by Rep. Geoff Diehl, R-Whitman, and several other GOP lawmakers would block local aid to communities such as Lawrence that have adopted ordinances or policies restricting local police from cooperating with federal Immigration and Customs Enforcement agents.

"These cities need to understand that they can't be harboring people who are skirting federal law," said Rep. Lenny Mirra, R-West Newbury, a co-sponsor of the amendment with Rep. Jim Lyons, R-Andover. "We need to be working with the federal government, not against it, to enforce our immigration laws."

Under Salem's "Sanctuary for Peace" ordinance, authorities do not question people's immigration status during routine interactions, such as when someone calls the police or another city department. It does not, however, prevent police from cooperating with immigration officials in criminal matters.

The proposal is one of nearly 1,400 amendments to the fiscal 2019 budget that lawmakers will begin to debate next week. The budget goes into effect July 1.

Diehl has made illegal immigration a key plank of his platform as he vies for the GOP bid to challenge U.S. Sen. Elizabeth Warren in the November elections.

Opponents of sanctuary cities say they hinder criminal investigations and local police should be working with federal authorities to enforce the law.

Immigrant advocates say requiring local police to cooperate with federal agents makes communities less safe because it dissuades people from reporting crime for fear of deportation. They say threatening to cut off local aid mirrors President Donald Trump's divisive policies.

"It's a transparent attempt to force the Trump deportation agenda on our communities," said Marion Davis, a spokeswoman for the Massachusetts Immigrant and Refugee Advocacy Coalition. "We know that lots of people with no criminal record whatsoever, and not just undocumented immigrants, are getting swept up in the deportation machine."

Local aid to cities and towns, which totals $1 billion in the current fiscal year, is a vital source of revenue for local governments that can be used for everything from hiring new police officers and firefighters to fixing potholes. Lawrence is slated to get more than $18 million in local aid this fiscal year.

A spokeswoman for Lawrence Mayor Dan Rivera didn't respond to a request for comment.

Besides Lawrence and Salem, five other communities in Massachusetts — Boston, Somerville, Cambridge, Amherst and Northampton — have declared themselves sanctuaries or passed similar ordinances. The rules vary widely by community, however.

In Lawrence, police will not hold immigrants suspected of illegally living in the United States unless a criminal warrant has been issued for their arrest.

On Beacon Hill, the controversial issue has divided policymakers.

A proposal to declare Massachusetts a sanctuary state — filed by Lawrence Democratic Reps. Juana Matias and Frank Moran, and Sen. Barbara L'Italien, D-Andover — is stalled despite more than 60 co-sponsors and a last-minute lobbying push from the state's police chiefs, who also support the measure.

Gov. Charlie Baker, a Republican, opposes a blanket ban on cooperation with immigration agents but says he won't stand in the way of communities that opt not to cooperate.

Last year, the Supreme Judicial Court said state law doesn't give police the authority to detain people suspected of illegal immigration unless they face criminal charges.

President Trump has vowed to crack down on sanctuary communities. The Republican signed an executive order last year vowing to withhold grants from those refusing to cooperate.

But the crackdown has been blunted by a series of recent federal court rulings that police cannot hold detain people at the behest of immigration agents.

Last week a U.S. District Court judge in California ruled that the Department of Justice was abusing its power in basing public safety grants on whether a municipal police force cooperates with immigration agents.

Christian M. Wade covers the Massachusetts Statehouse for The Salem News and its sister newspapers and websites. Email him at cwade@cnhi.com.