BOSTON — Lawmakers wrestled Friday with a proposal to make Massachusetts a so-called sanctuary state where cooperation between federal immigration officials and state and local law enforcement agencies would, by law, be sharply limited.

Hundreds of supporters and opponents of the measure crowded a public hearing, amid heightened concerns in some immigrant communities about President Donald Trump's deportation policies.

An executive order issued by Trump to cut funding to sanctuary cities has been blocked, at least temporarily, by a federal judge.

Republican Gov. Charlie Baker opposes the bill, arguing in a written statement that the legislation would "prevent the Massachusetts State Police from upholding our policy to detain individuals for federal authorities that have been convicted of heinous crimes, like murder and rape."

Supporters of the bill said it would improve public safety by reassuring those in the state illegally that they can communicate to local police — either as victims of crime or as witnesses — without fearing deportation.

"We know that when police act as immigration agents, immigrant victims and witnesses become afraid to talk to them," Eva Millona, executive director of the Massachusetts Immigrant and Refugee Advocacy Coalition, said during the hearing.

Ronnie Millar, head of the Irish International Immigrant Center, said some Irish immigrants are also particularly concerned about calls for a Muslim registry, given the long, and sometimes troubled, history of Irish immigration in Boston.

"As Catholic immigrants since the late 1800's, we remember well that the 'No Irish Need" signs hung in the windows of Boston businesses," he said. "We Irish know what it's like to be treated as a threat and to be dehumanized and to be kept under special surveillance."

Opponents say the bill could harm public safety.

Bristol County Sheriff Thomas Hodgson, who has offered to send inmates to the U.S.-Mexico border to help Trump fulfill his Republican campaign promise to build a wall, said it makes no sense to restrict the ability of Massachusetts to work with federal law enforcement agencies.

"Why should we share less information," he said. "Why is ICE cherry-picked as the one law enforcement agency that we can't partner with particularly given the escalating terrorist attacks, human and sex trafficking, gang violence and drug smuggling that's going on?"

Maureen Maloney, whose son Matthew Denice was killed in 2011 after being struck and dragged by a driver in the country illegally, also testified against the measure.

Maloney said her 23-year-old son survived an initial crash.

"Tragically, the unlicensed drunk criminal alien made the fatal decision to flee. He ran over Matthew and knowingly dragged him a quarter mile to his death," she said. "My son is dead because our lawmakers have put illegal aliens ahead of Americans."

Although dozens of legislators signed on as cosponsors of the bill, passage is far from assured. Democratic House Speaker Robert DeLeo, like Baker, has indicated a preference to leave sanctuary status up to individual cities and towns.

The proposed law would also bar creation of a Muslim registry; prohibit state and local agencies from entering into agreements with the federal government that call for "deputizing" employees to act as immigration officers; and require that anyone in detention be informed of their right to decline an interview with U.S. Immigration and Customs Enforcement agents.

The House recently put off action on a more narrowly-focused bill that would prevent state funds from being used to implement agreements between ICE and county sheriffs to provide training for correctional officers in immigration law enforcement. Bristol and Plymouth counties have entered into such partnerships.