Days before Donald Trump’s inauguration in 2017, Bristol County Sheriff Thomas Hodgson offered to send local prisoners to build sections of the former president’s border wall. He made headlines railing against the idea of Massachusetts being a sanctuary state, and stood against cities that sought to protect immigrants from involvement with federal immigration officers. He even flew 2,100 miles to Texas to honor border patrol and talk shop about deporting immigrants.

It’s that kind of staunch, hard-line rhetoric, action and mentality toward immigration policy that Hodgson brought to the table over his four six-year terms in office, and it may very well be the thing that brought his downfall in Tuesday’s general election.

That’s when Attleboro Mayor Paul Heroux, a Democrat, squeezed by Hodgson with 50.6% of the vote to his 49.4%, a difference of just over 2,000 votes. Immigration advocates who have spent years suing Hodgson over alleged and proven mistreatment of prisoners are elated.

“I think it's a big relief that Hodgson will no longer be returning as sheriff,” said Mario Paredes, an attorney who works at Prisoners’ Legal Services, an organization that has represented immigrants and prisoners filing cases against the county.

“It is incredible that it took so many years for the community to also understand that there was a high price for keeping someone like Sheriff Hodgson in office,” said Ivan Espinoza-Madrigal, executive director of Lawyers for Civil Rights.

In 2020, Lawyers for Civil Rights brought a successful class action lawsuit involving overcrowding and unsafe conditions at the immigration detention facility Hodgson oversaw — resulting in the ability for prisoners released on humanitarian grounds to quarantine at home.

“That high price was paid time and time again by taxpayers who had to foot the bill when lawsuits were filed and wrongdoing was addressed,” he said.

Hodgson's office released a statement to GBH News that said being elected sheriff and representing the public safety interests of Bristol County was the "biggest honor of his life." He said he will "work with the incoming-Sheriff to make the transition as smooth as possible."

Over 25 years, Hodgson oversaw hundreds of pretrial and convicted prisoners at three facilities, and — until mid-2021 — a federal detention center through a contract with US Immigration and Customs Enforcement. In September 2022, some 750 people were in his custody. The state’s longest serving sheriff earned an annual salary of about $172,000.

But critics cite many actions that concerned them in both the detention facility and the jails. Among them was a May 2020 incident when department staff members were involved in a violent altercation with immigrant detainees who were worried about being contaminated while being moved out of their unit and tested for COVID-19.

While commanding the detainees to leave the unit, Hodgson was involved in a physical dispute with a detainee, Marco Battistotti, who was on the phone with his lawyer. Both have versions of what happened. Battistotti said he was assaulted by Hodgson while still on the phone and then pepper-sprayed by other staff. Hodgson said he grabbed the phone when Battistotti refused, and then was “rushed” by a group of detainees. Shortly after, the immigrants barricaded themselves inside.

County workers, special force team members in riot gear, and a K-9 team showed up to make their way back into the unit. The fight ended with three detainees hospitalized, the rest in solitary confinement, and no Bristol County personnel hurt in the incident.

The confrontation was investigated by Attorney General Maura Healey’s office, which found Hodgson’s office “violated the rights of detainees by using excessive force and by seriously risking their health and safety.” The jail was under federal investigation for the same incident.

The fallout and consequence in May 2021 signified the beginning of the end for Hodgson. That was when the federal government terminated its contract with Bristol County Sheriff’s Office to hold immigrant detainees.

"Allow me to state one foundational principle: we will not tolerate the mistreatment of individuals in civil immigration detention or substandard conditions of detention," said Alejandro Mayorkas, the secretary of the Department of Homeland Security, at the time.

Hodgson called the move a “political hit job.”

Battistotti was released in 2021, and is one of a group of former prisoners suing Bristol County Sheriff’s Office, and Hodgson personally, for loss of due process rights, freedom from cruel treatment, assault, battery, poor medical care and use of excessive force. He told GBH News on Thursday that Hodgson’s “hard approach on immigrants" who are a “vital part” of the community didn’t seem to play out well with voters.

“It's overly aggressive. It bullies people and it costs the taxpayer a fortune,” he said. Battistotti supported Heroux during his campaign for sheriff. “He didn’t express any anti-immigrant sentiment whatsoever,” he said.

Paredes said that there were concerns that if any changes happened to the presidency — from Biden back to Trump in 2024 — Hodgson would make good on his hope to re-enter into a new contract with ICE to detain immigrants.

“I don't see any role for our sheriff's office to house ICE detainees,” said Heroux.

Heroux said he understands why people might get angry about “illegal or undocumented immigrants,” but that’s an issue for the federal government. “The border of Bristol County is Rhode Island, it’s not Mexico,” he said.

Heroux also defended immigrants, saying undocumented migrants have the lowest rate of committing crimes, even lower than U.S. citizens.

“The job of the sheriff is care, custody, control and rehabilitation. I don't plan on spending much time on the immigration issue,” he said. “A Massachusetts sheriff has no statutory authority to enforce federal immigration law.”

Other issues that impacted former immigrant detainees but still exist for the current jail population include high phone call costs and the mental health of prisoners.

Hodgson tried repeatedly to create a $5 per day inmate phone call fee, which was rejected by the Massachusetts Supreme Judicial Court. The phone rates at Bristol County’s jails were more than three times higher than those in state prison, and his office collected millions in payments for calls over the past decade.

In addition, suicides occur in Bristol County's jails more than other counties in Massachusetts; there have been at least22 since 2006. Lawsuits span the general population of prisoners and former immigrant detainees. One ongoing class action lawsuit challenges solitary confinement practices and alleges there was a failure to exclude people with mental illness from segregation and provide them with adequate health care.

Ira Alkalay, a Bristol County-based attorney who represents former ICE detainees, said Hodgson’s anti-immigrant rhetoric and his trips to the border repeatedly gave people the impression he had control over immigration policy.

“In reality, this isn't what the local sheriff's job is all about at all,” he said.

Heroux said that when he takes office he will take a fresh look at the lawsuits pending against the sheriff’s office.

'“If I hire a firm and they're saying to me, ‘Paul, you're going to lose this case, Hodgson was going to lose this case,’ I'm going to listen to them,” he said.