Two years ago, as others in California were limiting cooperation with federal immigration agents, the Fresno County Sheriff’s Department welcomed them into its jail.

Sheriff Margaret Mims gave U.S. Immigration and Customs Enforcement unrestricted access to databases and private rooms to interview inmates. She reorganized release times so agents could easily pick up people who had served their sentences.

The policy sparked outrage among immigrant rights groups, who called it a pipeline from incarceration to immigrant detention, one that they said disproportionately and unfairly affects Latinos.

“We are not anti-immigrant for working with ICE,” Mims said in defense of the approach. “We are anti-criminal activity.”

That belief is held by many of California’s 58 county sheriffs who will be on the front lines of implementing the landmark “sanctuary state” law, which Gov. Jerry Brown signed last month. It takes effect on Jan. 1.

Senate Bill 54 was introduced as a sharp rebuke from Democrats to President Trump ’s call for more deportations. It is designed to limit the people that California law enforcement agencies can detain, question or investigate at the request of federal immigration officials. But its impact will largely rely on county sheriffs whose departments play a vital role in immigration enforcement — and most of whom, like Mims, were opposed to SB 54.

Fresno County Sheriff Margaret Mims is one of many county sheriffs opposed to the "sanctuary state" law that will soon be implemented. Gary Kazanjian / For The Times

As keepers of jails across the state, sheriffs will retain control over who has access to the citizenship status of hundreds of thousands of people booked into their facilities every day. As elected officials, many represent conservative or rural areas, where voters might be more likely to oppose the new state law.

Sheriffs could also be subject to direct attacks from the Trump administration, which has threatened to slash federal funds from “sanctuary cities,” jurisdictions where local officials have passed ordinances and regulations limiting interactions between law enforcement and immigration agencies.

Trump built much of his campaign on anti-immigrant sentiment, showcasing the relatives of people killed by immigrants in the country illegally. His appointees have suggested illegal immigration is tied to increases in violent crime, though studies show immigrants generally commit fewer crimes than U.S. citizens.

U.S. Atty. Gen. Jeff Sessions has called SB 54 “unconscionable.” Thomas Homan, the president’s ICE director, has said his agency “would have no choice but to conduct at-large arrests in local neighborhoods and at work sites," prompting some in California's congressional delegation to request a meeting with Homan over his “reprehensible” comments.

In an opposition letter penned in March, Orange County Sheriff Sandra Hutchens saw the conflict coming, saying SB 54 would put sheriffs like her in “an unenviable position.”

a look inside a jail holding block at the Fresno Couty Jail. (Gary Kazanjian / For the Times) Sheriff deputy Alicia Perez books a prisoner at the Fresno County Jail. (Gary Kazanjian / For the Times) Sheriff deputy Joshua Anderson prepares a prisoner for booking at the Fresno jail facility. (Gary Kazanjian / For the Times) Top, a look inside a jail holding block at the Fresno County Jail. From left, Sheriff's deputy Alicia Perez books a prisoner at the Fresno County Jail. Sheriff's deputy Joshua Anderson prepares a prisoner for booking at the Fresno jail facility. (Gary Kazanjian / For The Times)

Though Trump has added new fuel to the debate, clashes between sheriffs and lawmakers over immigration enforcement have long existed in California, where previous legislative efforts to protect more than 2.3 million people living here illegally have sought to disentangle state and local law enforcement and federal immigration forces.

In 2014, the Trust Act prohibited law enforcement officials from holding immigrants past their release dates unless they have been convicted of one of roughly 800 crimes. The California Truth Act, which went into effect in January, requires officers to provide immigrant defendants notice of their rights prior to any ICE interviews.

The new ”sanctuary state” law was introduced to build on those laws. Officially dubbed the “California Values Act,” it will largely prohibit state and local law enforcement agencies from using personnel or funding to hold, question or share information about people with federal immigration agents unless they have been convicted of one or more offenses listed in the Trust Act.

Some sheriffs said the new law is unlikely to change the day-to-day work of deputies, who don’t question victims or witnesses about their immigration status while on patrol.

But unlike some city and campus police chiefs who threw their support behind SB 54, at least 40 of the 58 sheriffs in the state remained staunch opponents of the legislation through its passage. At least two — Jim McDonnell of Los Angeles County and Scott Jones of Sacramento County — drew protests for lobbying against it.

Now, they will be tasked with crafting new policies and training officers to limit their communication with ICE. Their agencies will also have to gather new statistics on the arrests made by task forces and on the people they transfer to immigration officials, reporting requirements under the law that are designed to provide insight into who is being swept up in the federal immigration dragnet.

Until now, counties have taken various positions when it comes to cooperation with ICE.

In San Francisco, for example, County Sheriff Vicki Hennessy filed a declaration in support of the city in its lawsuit against the Trump administration’s crackdown on “sanctuary city” policies. In accordance with the city’s laws, she wrote, the department maintains policies that limit notifying immigration officials on inmates’ release dates.

But in Orange County, Hutchens has a $7.27-million contract to incarcerate immigrant detainees convicted of crimes, as well as a $22-million annual lease to provide ICE with jail beds. Other sheriffs have granted federal immigration agents assistance behind the scenes. In L.A., McDonnell allowed them to set up an office with computers that provided information on released prisoners, according to a report released last month by an independent inspector.

In light of the new law, a statewide coalition of immigrant rights groups is already at work reaching out to sheriffs and drafting model policies of their own in hopes of creating parity among counties. Whether the new law can compel a cultural shift within departments will be up to sheriffs, advocates said.

“There is the letter of the law and specific things that the law states officers can or can’t do,” said Joseph Tomás Mckellar, co-director of PICO California, a faith-based community-organizing network. “But there is also the spirit of the law, which is, ‘Can we begin to look at immigrants differently?’ To see them as full human beings that can and do rehabilitate.”

A sheriff's deputy prepares a prisoner for booking at the Fresno jail facility. Gary Kazanjian / For The Times

In Fresno, where City Council leaders voted down a plan to provide legal services for immigrants and where former Arizona Sheriff Joe Arpaio , accused of racial profiling of Latinos, recently made an appearance at a GOP fundraiser, deputies and ICE officials have a closer working relationship.

Here, Mims has gone from being a registered Democrat to a Republican and has publicly quarreled with Brown over what she calls the Democratic Party’s hostility toward law enforcement issues, including gun rights and recent ballot measures to revamp the criminal justice system.

She also has been locked in battles with immigration advocates over the jail access she allows ICE, feuds that precede the election of Trump.

In September 2014, an Oregon federal court ruling prompted hundreds of cities and counties nationwide to stop holding inmates for immigration officials past their release dates, which had been permitted under a 2008 program by the Obama administration. After she heard the decision, Mims said she walked over to ICE’s nearby office in downtown Fresno to discuss ways they could continue their collaboration.

The meeting resulted in temporary work space for immigration agents at her jail, which holds about 25,000 to 30,000 people annually, and a restructuring of inmate release times that she won’t have to change under the new “sanctuary state” law.

Mims said her department is once more looking for ways to increase its collaboration with ICE in the wake of new communication restrictions.

“If ICE can’t do their job in a local, safe, controlled environment, they are going to put together teams, and they are going to go out into our communities,” she said. “I don’t think people are going to like the unintended consequences.”

Times reporter Mina Corpuz contributed to this report.

jazmine.ulloa@latimes.com

@jazmineulloa

ALSO:

California becomes 'sanctuary state' in rebuke of Trump immigration policy

How California's Trust Act shaped the debate on the new 'sanctuary state' proposal

Sacramento's sheriff asked Trump's immigration chief for help fighting California's 'sanctuary state' bill

Updates on California politics