CHICAGO — Security video captured the accidental shooting of a 12-year-old boy at a gas station on the city’s South Side.

The shooting happened just after midnight Friday on the 1400 block of East 87th Street.

Police said the boy was accidentally shot after a family member attempted to remove the handgun from their pants pocket.

The boy sustained a graze wound to the left hand and was taken to Comers Children’s Hospital in good condition.

Gas station security video shows the moment the male family member reached into his pocket and the gun discharged, striking the 12-year-old.

The man’s weapon was seized.

The Cook County State’s Attorney’s Office said Martin Guest, 61, was charged with reckless discharge of a firearm and aggravated unlawful use of a weapon, both Class 4 felonies.

A bail hearing has been set for 12:30 p.m. Saturday.

Area Two detectives are investigating the circumstances surrounding the incident.