A man’s anger over a beating carried out by his gang as punishment led him to kill another member last month at a Northwest Side apartment, prosecutors allege.

Jesus Hernandez, 20, faces a charge of first-degree murder in the Dec. 17 fatal shooting of 29-year-old Jermin Beganovic, the Cook County State’s Attorney’s Office said in court Wednesday.

Hernandez, who is also facing charges for allegedly choking his mother and fracturing her arm earlier this month, was denied bail.

“If you have no respect for your mother you have no respect for anyone on the planet,” Judge John Lyke Jr. said in determining bail.

In December last year, Hernandez was issued a violation by fellow members of the Insane Dragons street gang for taking another gang member’s gun without permission and selling it, prosecutors said. As punishment, he was ordered to take a two-minute beating from other members of the gang.

The gang carried out Hernandez’s punishment Dec. 16, which was recorded on video so that other members could see it, prosectors said.

After the beating, Hernandez and Beganovic attended a meeting between Insane Dragons members and then left together and went to Beganovic’s apartment in the 5300 block of North Cumberland, prosecutors said.

At the apartment, Hernandez complained about the beating, which he felt was undeserved. He also felt “insulted and humiliated” that the beating was recorded and being shown to other members, prosecutors said.

Early Dec. 17, Hernandez grabbed a loaded gun with an extended magazine that Beganovic kept in his apartment and shot Beganovic once in the head, prosecutors and the Cook County Medical Examiner’s Office said. The bullet came out his jaw and lodged in his arm.

Hernandez took Beganovic’s car and drove it a block away from his home in the Englewood neighborhood and set it on fire. Beganovic’s mother, the registered owner of the car, was notified and reached out to her son several times, prosecutors said. She found her son dead at his home later that day.

Surveillance video captured Hernandez’s movement in and out of Beganovic’s apartment on the night of the killing, and a speed camera recorded his turn onto the street where the vehicle was later found burning, prosecutors said.

An attorney for Hernandez said he was married with a infant child and worked temporary jobs to provide for his family.

He was scheduled back in court Feb. 7.