A 21-year-old man is in police custody after he accidentally shot himself Sunday on a Red Line train near the Garfield station in Englewood.

The man was riding a southbound train about 9:30 a.m. when his gun went off as the train pulled into the Garfield station, 220 W. Garfield Blvd., Chicago police said.

He later walked into St. Bernard Hospital with a gunshot wound to his right thigh, police said. Though the man initially refused to tell police where and how he was shot, he eventually admitted to shooting himself on the train and was released from the hospital into police custody.

Charges are pending against the man.