SOME MASSACHUSETTS POLICE CHIEFS appear to be staking out a different position than the communities they represent on how to handle detainer requests from the federal Immigration and Customs Enforcement agency.

The Massachusetts Chiefs of Police Association and the Massachusetts Major City Police Chiefs Association on Monday released an endorsement of legislation filed by Gov. Charlie Baker that would allow law enforcement officials to detain certain individuals sought by ICE who are on the verge of getting out of jail.

Support was overwhelming, with only two of the 50 members who voted from the associations remaining neutral and withholding their support. Officials declined to identify the two who declined to endorse Baker’s bill or name those who voted in favor.

“The governor’s bill is a commonsense, policy-prudent, and safety-oriented approach to addressing the existing ‘gap’ in the state of the current law,” the endorsement said, making a reference to a recent Supreme Judicial Court decision, Lunn v. Commonwealth, that barred state and local law enforcement officials from holding people without charging them with a crime. “Without this bill, state and local police would be unable to hold an arrestee, even one with a demonstrated propensity for violence and prior felony convictions, to allow federal agents to take arrestees into custody.”

Many of the communities represented by the police chiefs, however, have embraced so-called safe communities ordinances and laws that would bar or limit the ability of law enforcement officials to detain people on behalf of ICE. The language of some of those ordinances is similar to what’s contained in the governor’s bill, but critics have suggested Baker’s bill deprives those being detained of their due process constitutional rights.

Newton Mayor Setti Warren, who is running for the Democratic nomination for governor, has called Baker’s bill “un-American” because it lacks the due process rights contained in the Newton ordinance. Newton’s police chief, David MacDonald, is a member of the chiefs association. MacDonald could not be reached for comment.

Brian A. Kyes, the police chief in Chelsea and the head of the police chiefs association, said he voted to support Baker’s bill, calling its 12-hour detainment policy a “fair compromise” when compared to the 48-hour policy sought in most ICE detainers.

“We believe there should be a mechanism in place so the individual [in custody] isn’t just released after making bail and could possibly do another serious offense,” Kyes said, referring to a part of the bill that specifically targets individuals with serious criminal convictions.

Carol Rose, executive director of the American Civil Liberties Union of Massachusetts, issued a statement saying she was disappointed the police chiefs endorsed Baker’s bill, particularly since some of them have expressed support for legislation that she said would make communities safer and stronger while protecting the rights of immigrants. “Not only would [Baker’s] bill undermine public safety by causing residents to fear their local police; it would require litigation about its constitutionality.”

In addition to Baker’s bill on detainers, the Legislature also has before it a bill that would give local and state law enforcement officials tremendous leeway in working with ICE and another bill, the Safe Communities Act, that would bar officials from honoring any ICE detainers.

In Chelsea, 80 percent of the residents are of Hispanic or Latino descent and a lot of officers on the force are from Puerto Rico and speak fluent Spanish. As the city’s acting police chief, Kyes said he agrees with a lot of the points made within the Safe Communities Act but insists that proposal and the governor’s bill are completely different.

“This [Baker bill endorsement] has nothing to do with Safe Communities Act. It has everything to do with dealing with someone in custody,” the police chief said.

The two associations of chiefs attempted to take a stand on the Safe Communities Act before, but results were so mixed that they decided to remain neutral. The chiefs decided to take a vote this year on the governor’s proposal in the wake of the Supreme Judicial Court decision and after receiving a request for support from Baker’s secretary of public safety.

Chelsea officials have strongly opposed the Trump administration’s crackdown on immigration, and even filed a lawsuit with the city of Lawrence challenging the president’s plan to cut off federal funding to sanctuary cities.

The Chelsea City Council’s president, Leo Robinson, said he was unaware of the letter of endorsement signed by Kyes, but placed his full confidence in the chief.

“We have total faith in our police chief in how he thinks we should approach it [immigration enforcement],” Robinson said. “We want the bad guys to leave our city.”