State policy prohibits ICE officers from making arrests inside courtrooms. They must do their work in a hallway or outside a building. But on Thursday, Mr. Gonzalez and Eric T. Schneiderman, the state attorney general, held a news conference to say that even that was too much and that ICE should treat courthouses as sensitive locations — like hospitals, houses of worship and schools — where it does not make arrests. They said immigration authorities were interfering with the criminal justice system, making witness and defendants afraid to appear in court.

“I am asking ICE to reconsider their policy and treat the courthouse with respect,” Mr. Gonzalez said in the interview.

ICE has said that it goes to courthouses because it is safer than trying to detain someone at home or on the street. Sarah Rodriguez, the agency’s spokeswoman, said that despite the demand by the New York officials, “ICE plans to continue arresting individuals in courthouse environments as necessary, based on operational circumstances.”

Ms. Rodriguez said that those picked up by ICE “often have significant criminal histories.”

ICE officers have made 53 arrests in or around courts in New York State since January, compared to 11 arrests in 2016 and 14 in 2015, according to the Immigrant Defense Project, an advocacy group. Thirty-five of the arrests were made in or around city courthouses, including one on Thursday in Brooklyn.

The state Office of Court Administration said there were 52 instances of ICE officials identifying themselves to court officers; they made 30 arrests, 25 of which occurred in the city. The office did not keep statistics in previous years.