The New York Police Department will significantly limit the practice of seizing condoms for use as evidence in prostitution-related cases, ending a procedure that health officials had long criticized as undermining their efforts to protect prostitutes from disease.

The change, which the department announced on Monday, has the support of Mayor Bill de Blasio and the city’s five district attorneys. It allows for the continued practice of using condoms as evidence in cases involving sex trafficking.

“This is a reasonable approach to targeting the most at-risk community as it relates to safer sex practices and continuing to build strong cases against the vast criminal enterprise associated with prostitution,” the police commissioner, William J. Bratton, said in a statement.

Advocates for prostitutes and public health officials have been lobbying for this type of change for years, but attempts to pass legislation have repeatedly stalled.