The New York Police Department agreed Thursday to further cut back stop-and-frisk tactics – even as city investigators were using data gleaned from the practice to arrest the man now accused in a vicious sexual assault and murder.

The discovery of 30-year-old Karina Vetrano’s body in a Queens park in August made national headlines as authorities had very little information identifying her killer. But The New York Daily News reported it was a review of stop-and-frisk reports from the area near the crime scene that helped cops zero in on 20-year-old Chanel Lewis – who was arrested Saturday and charged with second-degree murder.

“To the extent that it’s not used as a national tactic, we all lose,” former New York City Police Commissioner Ray Kelly told Fox News. “It’s helpful in this case and that’s obviously a good thing, and quite frankly that should be standard practice. You look through all records.”

TRUMP SUPPORTS STOP-AND-FRISK

But the stop-and-frisk policy has come under attack nationally during the past several years, with New York City leading the charge to snuff it out. Thursday’s agreement – which curtailed stop-and-frisk in private apartment buildings – helped end a series of lawsuits against the NYPD, which has been the poster child for stop-and-frisk since a federal judge in 2013 ruled that one aspect of the policy was unconstitutional.

The debate resurfaced during the fall presidential campaign, with then-GOP nominee Donald Trump citing stop-and-frisk favorably during a televised debate and Democratic nominee Hillary Clinton telling a church group that evidence used to justify the program “doesn’t hold up under scrutiny.”

Then, New York City Mayor Bill de Blasio in a November speech said he would ignore a hypothetical order to be more aggressive in carrying out the tactic.

“If the Justice Department orders local police to resume stop-and-frisk, we will not comply,” de Blasio said.

But without old stop-and-frisk reports placing Lewis in the vicinity of Vetrano’s death, police might not have been able to amass enough evidence to eventually take him into custody. He reportedly confessed to the crime.

GIULIANI: TRUMP IS RIGHT ABOUT STOP-AND-FRISK

“To the extent that there’s been public attention on this, it has been the wrong kind of attention,” said Heather Mac Donald, a fellow at the Manhattan Institute who has written extensively on the criminal justice system. “Stops have to be conducted lawfully. There needs to be a threshold of needed suspicion. But if that stop is lawful, the police should be able to use that information in the future to solve crimes.”

Kelly, now the vice chairman at K2 Intelligence, a Manhattan cyber-intelligence firm, said some departments don’t have access to “that information,” charging that records aren’t being maintained and an unfavorable policing environment is leading officers to become skittish.

“If you look at it on a nationwide basis, crimes of violence, shootings and murders rising, I attribute that, certainly in pretty good measure, to the fact that police are not performing proactive duties that they were performing just a few years ago,” Kelly said.

Mac Donald said it will hurt an officer’s ability to thoroughly investigate crimes.

“You’re losing valuable information,” she said, “that the cops should have access to.”