NEW YORK (AP) — The New York Police Department will no longer confiscate unused condoms from suspected sex workers to be used as evidence of prostitution, ending a longstanding practice that had been criticized by civil rights groups for undermining efforts to combat AIDS and other sexually transmitted infections.

Under the new policy announced Monday, officers may continue to seize condoms as evidence in sex-trafficking and promotion of prostitution cases, but they will not use them in support of prostitution cases. Critics had said the previous policy amounted to police harassment, and noted that New York City spends more than $1 million a year to distribute free condoms.

“The NYPD heard from community health advocates and took a serious look at making changes to our current policy as it relates to our broader public safety mission,” Police Commissioner William Bratton said in announcing the new policy.

For decades, police in New York and elsewhere had confiscated condoms from sex work suspects ostensibly for them to be used as evidence in criminal trials, even though the overwhelming majority of prostitution cases never go to trial.

“A policy that inhibits people from safe sex is a mistake and dangerous,” Mayor Bill de Blasio said Monday at an unrelated event in Queens. “And there are a number of ways you can go about putting together evidence” without condoms, he said.

Civil rights groups and advocates for sex workers and gay, lesbian and transgender young people commended the department’s new policy, but want a ban on the use of condoms as evidence in sex trafficking and promotion of prostitution cases too.

They argue that even under the new policy police may continue to seize condoms from sex workers and teen runaways under the pretense of investigating pimps and traffickers, and that traffickers could punish sex workers who carry condoms because they fear they’ll be used against them.

“This is a step in the right direction but it doesn’t go far enough and creates a loophole big enough to drive a truck through,” said Andrea Ritchie, a coordinator at Streetwise and Safe, a New York City-based group that has long opposed the department’s previous policy. “We will be monitoring the NYPD carefully to see how they implement this policy.”

Measures to formally abolish the practice across New York state have been introduced in the Legislature for nearly two decades and last year passed the Assembly. Similar legislation has been introduced in California.

Corinne Carey, of the New York Civil Liberties Union, said lawmakers should go further than the NYPD by prohibiting law enforcement from seizing condoms as evidence of sex trafficking and other prostitution-related crimes.

“This (the new policy) is really too limited for us to be happy about it,” she said. “The message needs to be that condoms aren’t criminal.”

A 2010 study by the city’s Department of Health surveyed more than 60 sex workers and found that more than half had condoms confiscated by police. Nearly a third said they had at times not carried condoms because they feared getting into trouble.

Two years later, the group Human Rights Watch interviewed 197 sex workers in New York, Washington, D.C., Los Angeles and San Francisco and found that many limited the number of condoms they carried or went without because they feared police attention. The report concluded that transgender teens, street-level sex workers and immigrants were especially targeted because of their appearance or behavior.

Prosecutors in Brooklyn, Manhattan and Long Island’s Nassau County and in San Francisco stopped using condoms as evidence in prostitution cases last year.

The New York Police Department makes about 2,500 prostitution arrests a year.

One respondent in the Human Rights Watch study, Brooklyn sex worker Pam G., told the researchers she has had condoms taken by police.

“The cops say, ‘What are you carrying all those condoms for? We could arrest you just for this,'” she said. “It happens all the time around here. I may be carrying eight condoms. If you have more than three or four, they will take them.”