In a twist that left a neighborhood stunned, the 13-year-old cousin of an 8-year-old girl who was shot and killed while playing outside a South Los Angeles apartment building last week was charged Tuesday with her murder, authorities said.

The stray bullet that struck Jasmine Sanders in the chest was fired by her cousin, who was apparently aiming at a man who was also at the scene, prosecutors said. Initially, authorities suspected that it was the work of gang members who did not know the victim.

District attorney’s spokeswoman Sandi Gibbons said the boy, whose name is being withheld because he is a minor, was charged in juvenile court with murder and attempted murder. The shooting is believed to be gang-related.

Gibbons said the complaint alleges the boy used a handgun at East 76th and South San Pedro streets. He is scheduled to be arraigned today in Compton Juvenile Court.

LAPD Police Cmdr. Pat Gannon described the boy as a “gang associate” and said detectives are searching for a second suspect in the case.

He said the boy was “shooting at someone else” in retaliation for an assault that occurred earlier in the day when he hit Jasmine.

“It is a tragedy to lose an 8-year-old girl,” Gannon said. “It’s double tragedy when the boy who fired the weapon is barely 13.”

Jasmine was shot about 8:45 p.m. last Wednesday as she was playing with her younger brother and other children behind an iron gate near the stairwell of an apartment building, police said. Her mother, Shadonna Kinney, 28, tried to revive her after she was shot and later made a public appeal beseeching the shooters to turn themselves in.

Witnesses initially told police that two teenage boys approached the crowd from a nearby alley and that one of them, dressed in a white shirt and dark pants, fired a round at a group of male youths standing behind the stairs.

The force of the shot pushed Jasmine against the stairs, where her mother picked her up. Community members, police and neighbors held a vigil for Jasmine on Thursday night near the shooting site. Flowers, balloons and stuffed animals were left near the stairwell where Jasmine collapsed after she was shot.

Candles were handed out among the crowd as ministers led a prayer. Participants lifted their candles and sang: “In my neighborhood, I’m going to let it shine.”

Jasmine’s mother broke down in tears and was escorted to a nearby building, where she screamed and cried for about half an hour. “She didn’t deserve this,” Kinney had said. “She didn’t deserve this.”

richard.winton@latimes.com