In the Queens court on a recent Friday, the gallery was filled with mostly immigrant women sitting nervously beneath fluorescent lights. Signs in English and Chinese instructed them to turn off their cellphones as they waited for their names to be called and for translators to help them understand the proceedings. Sometimes women were accompanied by older men, who lawyers said they believed were pimps.

The nonprofits that work with the courts offer trauma counseling and consultations with immigration attorneys, as well as assistance navigating public health care, affordable housing and education programs. The more times women go through the court process, the more sessions they must attend.

“A lot of these girls are under the coercion and control of pimps. They can’t just go get health care or IDs or other services unless they go through the courts,” said Rachel Lloyd, the executive director of Girls Educational & Mentoring Services, one of the service providers.

Though it often takes years and multiple arrests, many service providers say they have seen the process guide people out of prostitution.

“It was really scary, but I’m grateful for it. If I wasn’t arrested, I’m not sure I would have made it out of the life,” said Adriana, 29, who was sex trafficked for six years. The Times is withholding her last name to protect her future job prospects. “Hearing other people talk about the bigger picture, about how they had been manipulated, that was really eye-opening.”

But some people in the sex trade — particularly immigrants — said intertwining the criminal justice system, which holds the threat of punishment, with social services that are intended to help, sends a baffling message.

A.G., a 33-year-old immigrant from China who went through the Queens intervention court, said she ultimately did not tell her assigned counselor much about her life in Queens or China. She is being identified by her initials because her family does not know she is involved in prostitution.