By ASTRID GALVAN

PHOENIX (AP) — Two years after New Mexico’s largest county barred local law enforcement from cooperating with immigration authorities, its leaders learned that the policy was being subverted from within.

Staff members at the Bernalillo County jail in Albuquerque were still granting immigration authorities access to its database and, in some cases, tipping them off when a person of interest was being released.

“I was surprised and horrified,” said Maggie Hart Stebbins, chairwoman of the Bernalillo County Commission. “Individual employees do not have the freedom to pick and choose what they want to observe.”

The disclosure last month cast a spotlight on an often-overlooked way in which immigration officials around the U.S. may be getting around local “sanctuary” policies — through informal relationships with police and others willing to cooperate when they’re not supposed to. Immigration activists say they have seen it places like Philadelphia, Chicago and several communities in California, which has a statewide sanctuary law.

On Wednesday, for example, the American Civil Liberties Union reported that emails show that a detective in Orange County, California, regularly looked up license plate information for an immigration officer.

“Often people underestimate the informal relationship between ICE and local law enforcement,” said Sara Cullinane, director of the immigrant-rights organization Make the Road New Jersey. She said a major way to make sure immigrant-friendly ordinances are being obeyed is training officers about what they can and cannot do.

Over 100 local governments around the country have adopted a variety of sanctuary rules barring police and jails from cooperating with immigration authorities, often by refusing to hold people arrested on local charges past their release date at the request of immigration officers who intend to pick them up.

Immigration and Customs Enforcement says these types of policies have made the streets less safe. The restrictions have also led the agency in the past couple of years to find other ways to make arrests, such as by staking out courthouses for immigrants, a practice ICE had generally avoided.

In 2017, the governing commission in Bernalillo County, population 680,000, barred the use of county money, resources or personnel to enforce civil immigration laws. County employees are not allowed to investigate, question or apprehend people based on their immigration status.

Last month, Bernalillo County passed another resolution further restricting county workers from sharing any sort of information regarding immigration status. A day later, on Feb. 27, the jail administration notified county leaders that it learned, while discussing the latest resolution with jail staff, that some had still been working with ICE in an informal way.

Staff members let immigration officers walk beyond the public areas of the jail and use the county computers, where they had logins to access inmate information such as names, places of birth and addresses. On occasion, staff would call immigration officers to let them know when an inmate was being released.

The county now bars ICE from going anywhere past the public areas. Nobody has been disciplined so far, said jail spokeswoman Candace Hopkins.

Hopkins said jail workers tipped off ICE regarding about one person out of around 3,000 released each month. “Our records department was complying with those requests with rare occasion. Extremely rare is something that we want to emphasize,” she said.

ICE said that accessing the jail database made the public safer by ensuring that criminals facing deportation weren’t released back onto the streets in the U.S.

“When sanctuary-city policies inhibit ICE officers’ ability to identify and take custody of criminal aliens in a controlled environment such as local jails, ICE is forced to dedicate its limited resources to track down fugitives and dangerous criminals upon release,” said Corey Price, an official with the ICE field office in El Paso, Texas, which covers New Mexico. He said sanctuary policies are “misguided efforts” by “those who ultimately want to shield dangerous criminals from being deported.”

In Chicago, police are barred from cooperating with immigration authorities in a number of ways, but ICE still had access to its gang database, advocates say. In 2017, the city settled with a man who sued after he was mistakenly placed on a gang database that ICE accessed and used to arrest him. Immigration officers seriously injured the man while arresting him at his home.

In Philadelphia, which since 2014 has prohibited its jails from holding detainees for ICE or notifying the agency of release dates, authorities even in high-level administrative posts were still informally working with the federal agency, according to advocates and an investigative report by The Philadelphia Inquirer . The newspaper documented about 10 occasions in which police notified ICE about immigrants they arrested.

Blanca Pacheco, co-director of the New Sanctuary Movement of Philadelphia, said that until last year, the city’s probation officers, who shared an office building with ICE, were walking clients over directly to the federal agency to turn them in, in violation of the city’s directive. Pacheco said the practice stopped when it came to light.

She said it went on largely because some people weren’t trained on the policies. Training “is really key because one thing is to win the policy, and another is to train people. There are people that, because of racism, do it, but also there are officers who just don’t know,” Pacheco said.

In another case of behind-the-scenes cooperation, the ACLU reported that ICE uses a license-plate recognition database containing information submitted by some 80 police departments, some of them in sanctuary cities that are not supposed to be cooperating with ICE.

Jorge L. Baron, executive director of the Northwest Immigrant Rights Project, an advocacy and legal services group in the Seattle area, said immigration agents have always found ways to get information on deportable criminals when it’s not easily accessible.

“We have to continue working on ways that we can prevent information-sharing,” Baron said.