Rahmir Ponzo has been charged with endangering the welfare of a child and recklessly endangering another person, according to police.
The shooting happened inside a home on the 5200 block of Delancey Street in West Philadelphia.
Police say a 2-year-old child accidentally shot himself in the stomach after getting the gun from a bedroom.
He was rushed to Children's Hospital of Philadelphia, where he's listed in critical condition.
A gun was recovered from the scene.
Police are also investigating an unrelated shooting involving a 5-year-old girl. Investigators say she was shot on the porch of a West Philadelphia home. No arrests have been made in that case.
RELATED: Check the 6abc Neighborhood Safety Tracker