San Francisco's 1989 sanctuary law grew out of the religious-based sanctuary movement through which churches across the country offered a safe haven to Central Americans who fled civil war and political persecution but were unable to gain asylum in the United States.

For local governments, however, the motivation behind sanctuary policies today has more to do with effective policing than humanitarian impulses.

"Some police departments say ... 'We don't want our police officers enforcing immigration law because if they do, victims and witnesses of crimes won't cooperate with us,' " said Kevin Johnson, dean of the UC Davis law school and an expert on immigration and civil rights law.

Last week, San Francisco's sanctuary ordinance came under fire after The Chronicle revealed the Juvenile Probation Department's practice of flying illegal immigrant teenagers convicted of drug offenses back to their home countries or housing them in unlocked group homes. Mayor Gavin Newsom denounced the practice, and city officials are now working with federal immigration authorities to develop a new approach for handling juvenile illegal immigrants who commit crimes.

Legal analysts, city officials and immigrant advocates say San Francisco's practice was not required - and not intended - by sanctuary laws.

Former San Jose Police Chief Joseph McNamara, who is now a fellow at the conservative Hoover Institution, was aghast at the San Francisco Juvenile Probation Department's approach: "It's just incredible to think they were spending all that money to help criminals evade being deported," he said.

But he directed his officers not to cooperate with federal immigration raids when he was chief from 1976 to 1991 and said the policy played an important part in rebuilding community trust in the department.

"There's a real debate going on nationally in police circles, but in almost every large city I know of, police departments have the same attitude: We have to work with these communities; we can't have them viewing the police as the enemy because then you get this 'Don't snitch' policy," McNamara said.

Richmond police spokesman Lt. Mark Gagan has said his department's policy is not to investigate immigration status on its own but to work with the federal office of Immigration and Customs Enforcement in dealing with violent criminals.

San Francisco is among scores of cities in California and around the country with sanctuary laws, according to the National Immigration Law Center. Several states also have such policies. The laws vary, but most bar the use of local resources to enforce federal immigration rules or prohibit police and other local officials from questioning residents about their immigration status. They do generally allow cooperation with federal immigration officials in dealing with criminals.

San Francisco's "city of refuge" policy arose in the 1980s when the United States was backing the governments of El Salvador and Guatemala and didn't recognize most of the refugees from those countries as having legitimate asylum claims.

Kathleen Healy, a nun with the Sisters of the Presentation, remembers working with St. Teresa of Avila Catholic Church to establish what is believed to be San Francisco's first sanctuary church.

"We felt we were doing the right thing, even though we were warned we could be arrested," she said. "We took three refugee women into our convent."

In 2007, faith leaders launched a new sanctuary movement geared toward protecting today's undocumented immigrants, most of whom are in the country for economic reasons.

A pledge drafted by the interfaith New Sanctuary Movement states in part, "We are deeply grieved by the violence done to families through immigration raids. We cannot in good conscience ignore such suffering and injustice."

Federal law doesn't require local governments to report illegal immigrants, but ICE officials encourage local and state law enforcement to collaborate.

"We understand there may be policies and procedures at the local level that affect the way that collaboration can occur," said ICE spokeswoman Virginia Kice. "Our goal is to impress upon local agencies the ways the community can benefit."

Federal immigration officials have been increasing their efforts to screen jail and prison inmates to find people who may be deportable, including both undocumented immigrants and legal immigrants who have committed certain felonies.

Some local officials - from Florida state troopers to Maricopa County, Ariz., sheriff's deputies - are getting training from federal immigration authorities and being deputized to enforce immigration law themselves.

"Why is it that some cities are sanctuary cities and some are tough on immigrants? That reveals the ambivalence we have as a nation toward immigrants of all sorts and undocumented immigrants particularly," said Johnson, the UC Davis dean. "This is one of the myriad issues that come up in immigration law that hopefully Congress and the new president will take up in the near future.

"Sometimes you want a policy even if you don't like what the policy is. I think the nation is yearning for a policy one way or another."

San Francisco's City of Refuge Ordinance

The ordinance reads, in part: "No department, agency, commission, officer or employee of the City and County of San Francisco shall use any City funds or resources to assist in the enforcement of federal immigration law or to gather or disseminate information regarding the immigration status of individuals in the City and County of San Francisco unless such assistance is required by federal or State statute, regulation or court decision."

The law was amended in 1992 to add: "Nothing in this Chapter shall prohibit, or be construed as prohibiting, a law enforcement officer from identifying and reporting any person pursuant to State an federal law or regulation who is in custody after being booked for the alleged commission of a felony and is suspected of violating the civil provisions of the immigration laws."

Sanctuary laws

More than 80 U.S. cities or states have sanctuary laws. They range widely from philosophical resolutions to more specific guidelines for police conduct.