Federal immigration officials, criticized for authorizing arrests at courthouses, say their agents will enter court buildings to seize specific immigrants but will not conduct sweeps in search of anyone else who is undocumented.

U.S. Immigration and Customs Enforcement “will not make civil immigration arrests inside courthouses indiscriminately,” the agency said in a policy statement distributed Wednesday. “ICE officers and agents should generally avoid enforcement actions in courthouses, or areas within courthouses that are dedicated to non-criminal (i.e. family court, small claims court) proceedings.”

Agents can go to courthouses to arrest immigrants who are wanted for crimes, are members of gangs, have ignored deportation orders or are “public safety threats,” the agency said, but others encountered in the courthouse, such as the immigrant’s relatives and friends, will not be picked up unless they pose a threat to public safety or interfere with the agents.

Opponents of the agency’s practices since President Trump took office differed sharply on whether the new policy statement was an improvement or merely a self-justification.

The most prominent of the previous critics, California Chief Justice Tani Cantil-Sakauye, said ICE appeared to be responding in an encouraging way.

“If followed correctly, this written directive is a good start,” she said in a statement. “It’s essential that we protect the integrity of our state court justice system and the people who use it.”

But San Francisco District Attorney George Gascón said the agency was wrongly defending a policy of continued courthouse arrests.

“As a career law enforcement professional,” said the former police chief, “I know it to be a fundamental truth that our neighborhoods are safer when people from all communities can work with law enforcement and come to our courthouses without fear that their immigration status will be used against them.”

In the same vein, Santa Clara County District Attorney Jeff Rosen said, in response to ICE’s policy statement, “All of us are put in danger when victims and witnesses grow too afraid to come to court, or even report crimes.”

Cesar Cuauhtémoc Garcia Hernández, a University of Denver law professor, was even more critical.

“ICE’s courthouse arrest policy sticks to its past practice of viewing courthouses as suitable locations for arrests” without “any meaningful limits,” he said. And he added that the agency is unfairly blaming local governments for their reluctance to deliver jailed immigrants to federal agents, “while ignoring the impact on witnesses, victims, and people who have not been convicted of any crime.”

He was referring to a portion of the policy statement that defended courthouse arrests.

“Courthouse arrests are often necessitated by the unwillingness of (state and local) jurisdictions to cooperate with ICE in the transfer of custody of aliens from their prisons and jails,” the agency said. “Further, many of the aliens ICE is targeting have taken affirmative measures to avoid detection by ICE officers. ... Civil immigration enforcement actions taken inside courthouses can reduce safety risks to the public, targeted alien(s), and ICE officers and agents.”

But ICE said it would refrain from making wholesale immigration arrests at courthouses. Before any enforcement action in civil areas of a courthouse, such as family court, an agent will need approval from a supervisor or office director, ICE said.

The issue was first spotlighted in March when Cantil-Sakauye, a former prosecutor, sent a letter to the federal agency after reports from California and four other states that ICE agents had shown up at courthouses to arrest immigrants for deportation, saying agents should stop “stalking courthouses.”

Later that month, in her annual speech to a joint session of the Legislature, she said immigration arrests, and the fear of such arrests, “will trickle down into communities, churches, schools and families, and I worry that people will no longer cooperate, or come to court to press their rights, or to seek protection because they will see the court as a bad place.”

California lawmakers have also responded. The state Senate this week approved SB183 by Sen. Ricardo Lara, D-Bell Gardens (Los Angeles County), which would require immigration agents to get a warrant from a judge, naming a specific individual, before conducting arrests, interrogations or surveillance at a courthouse or any other state building. The bill now moves to the Assembly.

Bob Egelko and Hamed Aleaziz are San Francisco Chronicle staff writers. Email: begelko@sfchronicle.com, haleaziz@sfchronicle.com Twitter: @BobEgelko, @haleaziz