After a gray sedan collided with his Minneapolis police SUV amid the downtown chaos, officer Efrem Hamilton figured it was the same car used in an earlier shooting and went into defense mode.

What he didn’t realize was that the carful of late-night partyers was trying to get away from the scene he was racing toward. The BMW’s 23-year-old driver testified in court that she never even saw the officer’s flashing lights.

But because Hamilton, 43, was reacting to a perceived threat in the moment, a Hennepin County jury on Tuesday cleared him of any wrongdoing for firing the single shot at the vehicle during the melee two years ago.

Prosecutors said Hamilton immediately got out of his squad vehicle and fired his 9mm Beretta service weapon once, without warning. The bullet struck the right rear door panel, stopping just inches from one of the car’s occupants.

After the not guilty verdict was read Tuesday, the normally stoic Hamilton heaved a sigh of relief, as his wife, who attended every hearing of the two-week trial, wept loudly from the front row. Hamilton asked for the opportunity to address the courtroom and through tears said that his life was forever changed.

“I’ve always put my life on the line to help people,” Hamilton said. “Now, I just realized the lives that mattered the most were those of my wife and family and kids.”

He also offered prayers for the car’s occupants and their families.

No one was injured in the Nov. 2016 shooting, but Hennepin County prosecutors still charged Hamilton, a rarity for an officer acting under the color of the law.

Jurors deliberated for about seven hours over two days before finding the officer not guilty on all counts: second-degree assault and two counts of intentional discharge of a firearm, all felonies.

He had just gotten off an off-duty job at a downtown bar when he responded to the call about a large brawl-turned-shooting near Target Field. After turning onto 3rd Avenue, his squad collided with the BMW, driving the wrong way down a one-way street. Hamilton testified that the car fit the description of the suspect vehicle as a “gray sedan,” and that he feared for his life when he heard what sounded like the driver revving the engine.

But prosecutors argued that the revving sound could have come from other cars in the area and that the BMW’s frightened occupants were only trying to get away from the shooting scene. Hamilton’s actions, they argued, were reckless and unnecessarily put others’ lives at risk.

In the end, the jury sided with the defense.

“You know there was a carful of innocent victims that was fired into,” said the jury foreman, who asked not to be named. “But you have to separate what happened after and what you learned after the fact from what the officer knew at the time that he applied deadly force.”

An investigation by the Office of Police Conduct Review cleared Hamilton of violating any of the department’s policies and procedures, but a final decision in the matter rests with Police Chief Medaria Arradondo.

In a statement Tuesday night, Arradondo said Hamilton remains a police officer with the MPD.

“As part of the MPD’s commitment to procedural justice, we ensure that all use of force incidents are taken seriously and investigated fully,” he said.

City officials later settled with the car’s six occupants — Deshaun Robinson, Devyn O’Curran, Chea Bemah, Caylea Wade, Michael Hughes and Thalia Johnson — for $150,000 to keep the matter out of court. And the department later changed its use-of-force policy to “strongly” discourage officers from shooting at, or from, moving vehicles. Instead, the policy said, officers “shall strongly consider moving out of the path of an oncoming motor vehicle” instead of firing at the vehicle or its occupants, thereby “minimizing the need for deadly force.”

Hamilton’s lawyer Fred Bruno said that County Attorney Mike Freeman only charged his client to prove his willingness to do so in cases of officers accused of wrong­doing, in the wake of his decision stop using grand juries in such cases.

“My guy was the first guy to come along, so he latched on to him to prove that he’s man enough to charge a cop,” Bruno told reporters after the hearing. “So Efrem was in the wrong place, in the wrong time — he was just the most locally accessible example to the community that cops are going to be charged.”

When reached for comment Tuesday afternoon, Freeman brushed off Bruno’s comments, saying that the veteran defense attorney “is known for his hyperbole.”

“The fact is, we have charged numerous police officers in the years prior to Officer Hamilton for everything from theft while on duty to criminal sexual conduct,” Freeman said in a statement. But, he didn’t mask his disappointment, saying, “We disagree with the conclusion but we respect the process.

“We continue to believe that Officer Hamilton should not have fired that shot at a car full of people within seconds of getting out of his car. We do not believe this was good police work and hope not to see such carelessness in the future.”

Minneapolis Police Federation President Lt. Bob Kroll said Hamilton was being singled out for charges because he was a police officer. He said Hamilton, who transferred to a desk job in the traffic investigations unit last fall after being put on leave following the shooting, was eager to get back onto the streets.

Local activist Mel Reeves, who has led protests over other controversial police actions, said the verdict was not altogether surprising.

“Cops can’t be right all the time,” Reeves said. “Juries not being able to convict [officers] is a problem.”