Last week was a bad week for crime victims and the police. Gunmen murdered five people in one night, and fears grew that in the wake of NYPD Officer Daniel Pantaleo’s firing five years after Eric Garner’s death, the police would stop doing their jobs. Recent examples from the subway system show how high the stakes are, if we don’t get crime prevention in the new political reality right — but also show that there’s a way to get it right.

The subway system is unique in NYC crime history. It’s where, in 1990, Bill Bratton launched his experiment in deterring small crimes to prevent bigger ones.

Every day back then, more than 200,000 New Yorkers — 6 percent of weekday passengers, twice the current level — were beating the fare, with almost no enforcement. The police cracked down and cut fare evasion, a good thing in itself.

They also found that a small but significant proportion of the fare-beating public was carrying guns or knives or was wanted for more serious crime like murder, rape, robbery or drug-dealing.

Misdemeanor arrests soared by 80 percent, and the technique worked. Five months after running a headline that predicted “No End to Rising Subway Crime,” the New York Times reported in early 1991 that subway crime had “dropped sharply at year’s end.”

In 1990, 26 people were killed in the transit system. Today, the transit system rarely exceeds two murders a year; the most recent year during which more than two people were killed was 2007, when the subway and buses had four murders.

The good news is that this technique still works. Consider some incidents from the past few months.

In mid-July, cops stopped a fare-beater in the Bronx. Questioning the suspect led police to obtain a search warrant for an apartment, where they found two guns, 100 bullets, heroin and tens of thousands of dollars in cash. In June, cops stopped ­another Bronx fare-beater and found he was carrying an illegal sword, plus some stolen credit cards.

In March, an Astoria fare-beating stop led to the suspect in a 2018 murder. And in February, cops chased down a fleeing fare evader and found he was fleeing for a good reason: He had an illegal loaded gun.

But how could cops keep sword- and gun-toters off the subway — when the political mandate in modern-day New York is to arrest fewer people?

Manhattan DA Cy Vance said a year and a half ago that he would stop prosecuting most turnstile jumpers — a signal to stop arresting.

It’s simple: Police, after a few months of glitchy adaptation, have changed tactics. Arrests for jumping the turnstile — or going through the exit door — have plummeted. For the first six months of this year, police made 1,936 arrests for evading the fare — 49 percent below last year’s half-year level.

But the number of civil summonses — more like a traffic ticket than a criminal case — soared to 49,619, from 31,517.

Police have largely replaced arresting people with giving them summonses. In the first six months of 2017 — before Vance made his announcement — police reported 50,633 fare-beating arrests and summonses combined. Now, the total figure is 51,555.

It’s just that a much lower percentage of the mix — 4 percent, rather than 20 — is criminal, not civil.

But all still are interactions with people who are breaking the law — and an interaction can lead to greater results. In the case of the fare-beater who led to the armed heroin dealer, for example, cops would have given him a summons, rather than arrested and questioned him — except that they found that he was a repeat offender.

In the February case, the gun-toting suspect was subject only to a summons until he fled.

Police are still confronting fare-beaters, not ignoring them (albeit not perfectly — too many people still walk through exit gates unimpeded).

And serious crime underground has stayed low, even as quality-of-life challenges like vagrancy — which require more of a long-term mental health solution than a policing solution — have soared. The felony rate on the transit system — about six and a half crimes a day — is slightly lower than it was at the end of the Bloomberg era.

This works above ground, too. Last week, cops stopped a double parker in Harlem — and, in addition to stopping what should be the capital crime of blocking traffic, found an illegal handgun.

Despite political turmoil, police are still doing their jobs, and that’s partly why, despite bad nights like the one last week, in which five people died across two boroughs, the city’s murder rate is down 4 percent against last year’s low levels.

To be sure, these are hardly perfect conditions in which to fight crime — and police always need the threat of arrest, without having to make an actual arrest, to do their jobs. But even as it has to get more creative, there’s no sign yet that the NYPD is ceding the streets to crime.

Nicole Gelinas is a contributing editor of City Journal. Twitter: @NicoleGelinas