SAN FRANCISCO — In the debate over illegal immigration, San Francisco has proudly played the role of liberal enclave, a so-called sanctuary city where local officials have refused to cooperate with enforcement of federal immigration law and undocumented residents have mostly lived without fear of consequence.

But over the last year, buffeted by several high-profile crimes by illegal immigrants and revelations of mismanagement of the city’s sanctuary policy, San Francisco has become less like its self-image and more like many other cities in the United States: deeply conflicted over how to cope with the fallout of illegal immigration.

At the center of the turnaround is a new law enforcement policy focused on under-age offenders who are in this country illegally. Under the policy, minors brought to juvenile hall on felony charges are questioned about their immigration status. And if they are suspected of being here illegally, they are reported to the Immigration and Customs Enforcement agency for deportation, regardless of whether they are eventually convicted of a crime.

“We went from being one of the more progressive counties in the country to probably one of the least, and the most draconian,â€