He was 12 years old when he watched his older brother get stabbed in the heart on a San Francisco sidewalk and then bleed to death during a car ride to the hospital.

Five years later, the younger brother of Rashawn Williams is facing a murder charge himself, in what authorities believe is a case of retaliatory violence. The juvenile, whom The Chronicle is not naming because he is 17, was charged in September with fatally shooting Luis Quiñonez, a young man who was once accused of killing Rashawn.

Rashawn’s killing on Sept. 2, 2014, stunned San Francisco. He was 14 years old and immensely popular in the Mission District, where he went to middle school. He had a budding group of friends at Sacred Heart Cathedral Preparatory, where he enrolled on a scholarship and played on the freshman football squad.

For a moment, it seemed, justice in his case would be served. Days after the killing, police arrested Quiñonez, who was then 14, on suspicion of murder. But he was later freed after video proved he was not the stabber.

The footage showed someone who was with Quiñonez stabbing Rashawn in front of Rubin’s Market at 26th and Folsom streets. That boy was never arrested, though police believed they knew his identity.

A year later, that boy — whom The Chronicle is also not naming, because he was never accused of a crime — was shot to death in Bernal Heights. The killing remains unsolved.

The unraveling tragedy has left three teens dead, families grieving and now another boy behind bars in juvenile hall. He faces a life-altering punishment if convicted for his alleged role in the latest killing.

The case exposes the profound harm of street justice in cities such as San Francisco, with tit-for-tat attacks often cascading for years. In neighborhoods like the Mission, the fear of such violence — and the historic distrust between police and some residents — can worsen the problem, with witnesses and victims unwilling to cooperate with law enforcement.

Authorities have not said whether any witnesses to the 2014 stabbing, including Quiñonez or Rashawn’s brother, cooperated in the investigation.

Quiñonez’s family members place much of the blame on police in their boy’s death. Had investigators arrested Rashawn’s killer, they said, it might have brought some comfort to Rashawn’s friends and relatives, while reaffirming Quiñonez didn’t do it and taking a target off his back.

“I believe that the police and prosecutors knew who the suspect was,” said Luis’ father, René Quiñonez. “Why wasn’t that young man arrested and tried? Even though prison isn’t somewhere a family wants to visit, at least it isn’t a cemetery.”

The city police force and anti-violence groups have put a priority on stopping retaliatory bloodshed through community-focused policing and other programs — and in many cases the effort has worked. Youth violence in San Francisco and around California has dropped sharply over the past decade. But the danger remains.

“This is one of the most tragic things that can happen,” said San Francisco Superior Court Judge Daniel Flores, who presided over a hearing in juvenile court last month in the case against Rashawn’s brother.

Flores disclosed that he knew members of the defendant’s family as well as members of Quiñonez’s family before the case came to his courtroom, which he said “brings to heart and highlights how sad and tragic this situation is.”

The families of the victim and defendant packed the court gallery at a recent hearing — the same grieving people who five years ago filled the same building when Quiñonez was charged. In a cruel turn in the saga, their roles are now reversed.

“At some point I strongly believe that if we don’t address violence as a community, then it’s going to impact all of us,” René Quiñonez said. “And law enforcement has to be held accountable in addressing the cases where they can clearly make arrests — like the young man that killed Rashawn.”

San Francisco police officials would not reveal details of the case but said they “thoroughly investigate crimes.”

“It is very important to have cooperation from the community and have witnesses that are willing to come forward and testify,” said Officer Adam Lobsinger, a agency spokesman. “SFPD homicide investigators maintain a close working relationship with the San Francisco district attorney. A strong relationship between the police, prosecutors and the community is integral in solving and prosecuting crimes.”

Rashawn’s family has declined to speak with The Chronicle. The attorney for the teen charged with murder, George Lazarus, stressed that his client is presumed innocent and that “this is a tragic state of events.”

“I can’t go into depth based on the privacy of juveniles, and we’re still in juvenile court,” Lazarus said.

Rashawn was a few days into his freshman year at Sacred Heart and aspired to attend an Ivy League college. Months before his death, during the previous school year, he attended Buena Vista Horace Mann in the Mission with Quiñonez.

The boys had run-ins and administrators were notified about tension between them, according to a lawsuit Rashawn’s family filed against the school district, which was later dismissed. The family accused Quiñonez of bullying their son and said the school district did nothing to intervene.

The day he was killed, Rashawn was in the Mission after school with his two brothers, ages 6 and 12, along with his mother, Roxana Morales, and infant sister. The three brothers ran to Rubin’s market to buy candy while their mom waited near the car a short distance away.

At the same time, Quiñonez and another boy were walking up Mission Street. A security camera at the McDonald’s on 24th Street captured them heading south toward the market. What happened next was captured on another security camera across from the market.

Quiñonez and the other boy walked west past Rubin’s and began to round the corner when Rashawn walked out of the store. The two boys then turned back toward Rashawn. It’s unclear what was said, but the three stood in front of each other for about 15 seconds as Rashawn’s two brothers came out and stood nearby.

Then, in a flash, the grainy security video showed an arm dart toward Rashawn, striking him in the chest. Rashawn stumbled backward before turning and running toward his mother’s car, with his brothers following. Quiñonez and the second boy ran in the other direction.

“Roxana Morales rushed Rashawn Williams to the hospital in her vehicle as fast as she could,” the family’s attorney, Sandra Ribera Speed, wrote in the lawsuit. “During the car ride to the hospital, in front of his mother Roxana Morales and younger brothers … Rashawn Williams bled as he struggled to survive the stab wound to his chest. By the time he arrived at St. Luke’s Hospital in San Francisco, Rashawn Williams was unresponsive.”

It was only half a mile away, but St. Luke’s didn’t have a trauma center, so Rashawn was rushed to San Francisco General Hospital, where he was pronounced dead from a stab wound to the heart.

The killing drew wide media attention, and hundreds of Rashawn’s friends and relatives packed his funeral at the Cathedral of St. Mary of the Assumption. For days, members of the Mission community gathered at the scene of the stabbing to hold vigils for the slain teen.

Quiñonez was arrested shortly after the killing and held in juvenile hall on a murder charge, which he denied. Rashawn’s family pushed to have him tried as an adult, and prosecutors scheduled a fitness hearing in which a judge would have decided whether Quiñonez was eligible for adult court.

Three months later, San Francisco Public Defender Jeff Adachi called a news conference and released the security videos. Adachi’s office had tracked down the McDonald’s video, clearly showing what each boy was wearing before the run-in.

Adachi, who died in February, played the video from outside the store that he’d obtained from prosecutors and pointed out that Quiñonez was not the boy who did the stabbing. Almost two months later, the district attorney’s office dropped all charges against Quiñonez, who was released.

According to his family, Quiñonez went on to use his experience to help others. He earned a fellowship with the Dream Beyond Bars program in Oakland, advocating for policy changes in the criminal justice system.

It was Sept. 8 — nearly five years to the day after Rashawn was killed — when Quiñonez was shot dead at age 19.

He had been helping his girlfriend’s mother move, and was driving to get dinner with her family, when he stopped to put air in his tires. Quiñonez and his girlfriend pulled over on the 300 block of Rolph Street, near Crocker Amazon Playground, to call her mother when someone opened fire on the car, police said.

Quiñonez was shot multiple times. His girlfriend was struck in the arm as she pulled him toward her to protect him. The girlfriend has since recovered. Quiñonez died at the scene. Rashawn’s brother was arrested two weeks later.

Evan Sernoffsky is a San Francisco Chronicle staff writer. Email: esernoffsky@sfchronicle.com Twitter: @EvanSernoffsky