What were they thinking?

A Queens jury Wednesday inexplicably acquitted Guy Rivera of the top charge of first-degree murder in the death of NYPD Detective Jonathan Diller, depriving him, his family and all of New York of a full measure of justice for a hero cop.

Yes, the jurors found Rivera guilty on a host of lesser charges — aggravated manslaughter, attempted murder and weapons possession — which could (and should) send him to prison for life.

But it’s beyond baffling that any group of 12 reasonable people could have learned the facts of the case, listened to the testimony of Det. Diller’s brother officers and watched the bodycam footage of the homicide and not concluded that Rivera acted willfully and intentionally to murder the officer.

To refresh memories of the horrible case: On Mar. 25, 2024, four cops, including Diller, saw Rivera walking in Far Rockaway with a clear outline of a gun in his sweatshirt as he entered a car.

When Rivera refused to roll down his window or exit the vehicle, Det. Diller advised his team to pull the armed creep from the car.

More From Post Editorial Board

What happened next is the crux of Rivera’s defense: While being removed from the car, his lawyer argued, Rivera’s gun “went off” because his arm was being pulled.

But why had Rivera drawn his weapon in the first place if he had no intention to use it?

Furthermore, guns only “go off” in movies. In real life, the trigger has to be pulled.

Not to mention that after shooting Diller, Rivera rammed his gun into the chest of another officer, Sgt. Sasha Rosen, and tried to pull the trigger.

Get opinions and commentary from our columnists

Subscribe to our daily Post Opinion newsletter!

Thanks for signing up!

Fortunately, the firearm jammed, sparing the NYPD from losing two officers that day.

Cops have a thankless job, bracing gun-toting thugs like Rivera, who had a record of 21 prior arrests.

And they understand the job entails risks; they know that every day could be the last one they kiss their families goodbye.

But part of what motivates them to do the next hard thing, amid declining police morale, is knowing the good people of New York have their backs.

Here’s the latest on the shocking mixed verdict reached for career criminal who killed NYPD hero Johnathan Diller

That they know the danger they face, and care.

By refusing to find him guilty of murder, the jury in the Rivera case only further demoralized the thin blue line that stands between us and violent disorder.

Commissioner Jessica Tisch aptly summed up the feelings of 35,000 sworn officers in response to the verdict: “The failure to convict on Murder One landed like a gut punch to all members of the NYPD.”

Hear, hear.

It’s good that Guy Rivera will face a long prison sentence, though absent a murder conviction, his chances of getting out on parole in 10 or 15 years are stronger than if he were facing a true life sentence.

But our cops face serious danger on the streets. And when they are attacked, let alone slain, they deserve every bit of justice.

It’s the least we can do to send them on their shifts confident that we appreciate the risks they face.