Contra Costa County is severing its contract with the federal government to incarcerate undocumented migrants at a jail in Richmond, a pact that had drawn increasing attention and protests as the Trump administration intensified its crackdown on illegal immigration.

Sheriff David Livingston announced the decision Tuesday, making Contra Costa the second county in Northern California to cut contractual ties with the federal Immigration and Customs Enforcement agency in the past month.

“There is not one single overriding issue that causes the termination of this contract,” Livingston said at a news conference in Martinez. But he said public pressure had contributed to his decision.

“The outstanding work by the over 1,000 employees of the office of the sheriff has been overshadowed by the attention the ICE contract brings, even though immigration is a matter of federal law,” Livingston said. “Managing protests in Richmond have become expensive and time-consuming for our staff.”

The sheriff said those rising costs weren’t being covered by the federal government.

There are about 200 ICE inmates at the West County Detention Facility at any given time. The county has long had a contract with the U.S. Marshals Service to house federal prisoners, and in 2010 it agreed to incarcerate undocumented immigrants there while they awaited deportation proceedings.

The ICE agreement brought in about $3 million in net revenue for the county, according to the sheriff. Some of that money pays for sheriff’s deputies whom Livingston does not want to lay off. For the upcoming fiscal year, the money will be replaced by state and county reserve funds, he said.

The pact gives the sheriff unilateral authority to cancel the contract with 120 days’ notice. Livingston told ICE of his decision this week.

ICE officials expressed disappointment at the move.

“The decision to no longer house ICE detainees at the West County Detention Facility will negatively impact local ICE operations; however, the impact will be greater for those who would have been detained at the facility,” said Richard Rocha, a spokesman with the federal agency.

“Now, instead of being housed close to family members or local attorneys, ICE may have to depend on its national system of detention bed space to place those detainees in locations farther away, reducing the opportunities for in-person family visitation and attorney coordination,” Rocha said.

Karen Mitchoff, chair of the county Board of Supervisors, said she was sorry Livingston was pulling out of the contract.

“I think every member of the Board of Supervisors is against President Trump’s policies. They are abhorrent,” Mitchoff said. “But we have to deal with the cases before us. We are facing a budget deficit. ... It is the Contra Costa County taxpayer who will have to fill that hole.”

She added, “Unfortunately, with the closure of this facility, individuals that ICE is not able to release through normal processes will be sent to other facilities and will no longer have easy access to family members during a trying time.”

Supervisor John Goia, who had called for the county to cancel the contract, said housing ICE detainees “erodes the trust between local government and local law enforcement and our immigrant communities. Ending the contract is a critical step in rebuilding this trust.”

The jail has been the target of protesters for months, most recently on June 30, when more than 1,000 people gathered there as part of nationwide demonstrations against the Trump administration’s policy of separating migrant children from their parents at the southern border.

Last year 27 women being held on immigration charges at the jail signed a letter complaining about conditions there, saying they were being locked up for hours and told to use bags in their cells when they needed to go to the bathroom. The Sheriff’s Office said it had conducted an investigation and that “nearly all of the complaints” were unfounded.

A similar contract to house ICE detainees also proved controversial in Sacramento County. Last month the Board of Supervisors there voted to back out of the county’s contract with ICE to provide jail beds at the Rio Cosumnes Correctional Center. Most of the detainees were moved to Colorado, ICE said. Some were taken to Southern California and Hawaii.

Susan Lange and other advocates for immigrants in Sacramento are trying to keep track of detainees who have been moved out of state and stay in touch with families left behind.

“Families are not happy that they are so far,” Lange said of the families. “It’s very difficult.”

While some advocates see Contra Costa County’s move as a step in the right direction, they are calling on ICE to release the inmates rather than move them to another jail.

“ICE has the discretion to release every person in the immigration wing of West County Detention Facility,” said Ali Saidi of the Contra Costa Immigrant Rights Alliance. “ICE’s statement is disingenuous in that it gives the impression that they have no choice but to separate families and limit access to legal services, when all they have to do is not keep people imprisoned for civil immigration proceedings.”

Advocates also want the sheriff to expand hours for family and legal visits in the run-up to the end of the contract, said Saira Hussain, a staff attorney with Asian Americans Advancing Justice-Asian Law Caucus. They will also be raising money for detainees who are eligible for bond.

Jesse Lloyd, an immigration attorney who runs the law firm Bean and Lloyd LLP, said he understood why counties would back out of what have become controversial detention contracts with ICE. But he said there was no easy answer to the problem of detainees being moved far from their families.

“On a practical level, this is really bad,” Lloyd said. “If people are going to be detained, it’s better they are detained locally.”

Hamed Aleaziz and Rachel Swan are San Francisco Chronicle staff writers. Email: haleaziz@sfchronicle.com, rswan@sfchronicle.com Twitter: @haleaziz, @rachelswan