First a gunshot rang out. Then there was screaming.

Now, James J. Jenkins is being held on $500,000 bail, after his 3-year-old son was accidentally shot in the head Friday evening inside Jenkins’ West Garfield Park home.

Jenkins, 26, left a loaded .32 caliber handgun unattended where children could reach it, prosecutors said. He was charged Sunday with felony unlawful use of a weapon by a felon. The boy, also named James, remains at Mount Sinai Hospital, where his condition was stable, authorities said.

Jenkins and the boy’s mother were with family members on the porch of their home when 3-year-old James went inside to change clothes, along with his 5-year-old brother and 7-year-old half-brother, Assistant State’s Attorney Alex Molesky said during a court hearing Sunday.

What happened next remains unclear. But after a boom echoed out from inside the house in the 4300 block of West Monroe, the adults on the porch rushed inside, prosecutors said.

They found the two older boys crying. Meanwhile, James lay on the floor, bleeding from his head, with a black handgun by his side, prosecutors said.

Pulling the boy close, his father wailed: “I’m going to jail. What have I done?” Molesky told Judge Adam Bourgeois Jr.

After an ambulance was called, Jenkins grabbed the gun and left the house, prosecutors said. Jenkins, who was paroled in May after serving part of a 2 1/2-year drug sentence, was arrested Saturday, according to court records.

Though Bourgeois set Jenkins’ bail at $500,000, he will be held in Cook County Jail because a hold was placed on his release by the Illinois Department of Corrections.

Email: bslodysko@suntimes.com

Twitter: @BrianSlodysko