A 4-year-old boy accidentally shot and killed his 2-year-old cousin at a home in a Southern California town Friday, and their grandfather was later arrested for allegedly leaving the gun in a place accessible to the children, authorities said.

Cesar Lopez, 53, was charged with child endangerment and being a felon in possession of a firearm, the San Bernardino County Sheriff’s Office said in a news release.

Deputies and medical crews responded to the mid-morning shooting in Muscoy, a small town of around 10,000 people located east of Los Angeles, and found a toddler suffering from a gunshot wound, police said.

Neighbor Bubba McBath told KTLA-TV he heard the family's screams to call 911, and later saw the girl taken into an ambulance, apparently shot in the chest.

The young girl died less than an hour later at a local hospital, police said.

"That was her only daughter. She was a good mom." — Citlaoy Plascencia, neighbor

Investigators identified the children, who reportedly both lived in the same house with their mothers, as cousins. Family and neighbors were overwhelmed by the tragedy.

"That was her only daughter. She was a good mom," neighbor Citlaoy Plascencia told NBC Los Angeles.

“This is negligence here,” neighbor Dantra Lewis told the San Bernardino Sun. “I know these people are hurting, but a 4-year-old shouldn’t know where a gun is kept, let alone have access to it.”

Investigators interviewed several adults who were at the home during the shooting and determined Lopez had left the gun in an unsecured spot where the kids could find it.

The names of the children weren't released. The investigation is ongoing, police said.