The man accused of firing on protesters at a Minneapolis police precinct last fall was denied a bail reduction at a Wednesday court hearing fraught with emotion.

“Go back and rot!” a woman in the courtroom gallery yelled at Allen “Lance” Scarsella moments after Hennepin County District Judge Hilary Caligiuri ruled against lowering the $500,000 bail that would free him from jail.

The judge quickly told her and others to stop commenting, one of the several times she had to admonish disruptive behavior from the overflowing crowd. Many had gathered to support the five victims Scarsella is charged with shooting outside an encampment to protest the shooting death of 24-year-old Jamar Clark by police in November. The hearing also took place the day after the shooting death of Alton Sterling — who was killed by Baton Rouge, La., police officers — was captured on video, sparking protests across the country.

Sheriff deputies turned away a number of people once the gallery seats were filled. Scarsella’s family, who sat quietly during the hearing, was escorted from the courthouse by deputies.

The bail for Scarsella, 24, of Lakeville, was set with conditions during a December ­hearing. His attorney Peter Martin argued that he wasn’t a flight risk or a danger to public safety.

“We believe the evidence now shows he shot in self-defense and the defense of others,” he said. “He’s eager to get back to his normal life.”

Scarsella has been in jail since he was arrested in November, much of that time spent in isolation because of safety concerns. Martin detailed his absence of a criminal history, his potential job employment, family support and his involvement in the community.

While Martin made his arguments, Caligiuri told a man in the gallery to stop shaking his head. The man, who was calling Scarsella a racist before the hearing started, eventually left. Six deputies were assigned to the hearing, an unusually high number for a pretrial court date.

Scarsella is the only one among four co-defendants charged with first-degree assault for pulling the trigger Nov. 23 at an encampment assembled to protest the death of Clark, a black man shot during a struggle with white officers. The others were charged with second-degree riot while armed.

According to witnesses, about a dozen protesters attempted to move Scarsella and three others — Daniel Macey, Joseph Backman and Nathan Gustavsson — from the encampment outside the Police Department’s Fourth Precinct station when Scarsella fired, hitting five people.

The victims — all black men ages 19 to 43 — were taken to hospitals with noncritical injuries. Macey, Backman and Gustavsson were charged with second-degree riot while armed and have been released on bail.

Martin said Scarsella was chased by protesters and shot in self-defense, which he plans to present if the case goes to trial.

Assistant Hennepin County Attorney Judith Hawley said no circumstances had changed since Caligiuri first set bail. Scarsella or the co-defendants haven’t given an official statement to police that shots were fired in self-defense, she said.

Scarsella came armed and wearing a mask to the encampment that was racially charged, she said. Racial statements were made in a video he made days before the shooting, and he had texted several of the other co-defendants that “he was going to stir things up,” she added.

He called a friend to help him get rid of his handgun and ammunition, Hawley said.

As far as any trauma caused by being in isolation, deputies asked Scarsella if he wanted to return to general population. He told the deputies his attorney advised him to deny the offer, she said.

Caligiuri agreed that he continues to be a threat to public safety. He is facing a possible seven-year sentence if convicted of first-degree assault.

Cameron Clark, Jamar Clark’s nephew, was one of the shooting victims who attended the hearing. He was joined by Wesley Martin, who was shot in the leg by Scarsella. He isn’t paralyzed, but he said a doctor told him last week that he won’t regain feeling in his leg.

“If he gets out, what if he does something else?” he said before the hearing. “He should have been charged with attempted murder.”