A 10-year-old boy walking home from school was shot in the back of his head Wednesday in the city’s Frankford section, apparently an unintended target, Philadelphia Police said.

The shooting took place around 3:30 p.m. on the 2000 block of Margaret Street, near Torresdale Avenue. The boy was walking home from James J. Sullivan School when he was struck by gunfire from the back seat of a red or maroon Pontiac G6, Deputy Commissioner Joseph P. Sullivan said.

The boy, identified by police as Sameje O’Branty, was taken to St. Christopher’s Hospital for Children, where he was listed in critical but stable condition, Sullivan said. No one else was injured.

Cheri Honkala, a longtime Philadelphia anti-poverty activist who said she is a close friend of the boy’s family, said his first name is spelled Semaj.

Police also took a man into custody who may have been the intended target and who apparently fired back at the Pontiac. Video surveillance shows the man firing five shots at the car, said Capt. John Walker. After firing at the Pontiac, the man helped the boy by dragging him into the driveway behind a corner store at Torresdale and Margaret, Walker said.

A revolver that investigators believe was used to return fire at the Pontiac was found in a recycling container near the store, Walker said. The boy’s mother was inside the store when he was shot, Honkala said.

The shooter in the vehicle remained at large.

Police released a photograph from surveillance camera of the car sought in the shooting.

Jahaira Cruz, 39, of Hunting Park, a certified medical assistant, said she was visiting a friend on Margaret Street when they heard six or seven gunshots, then the sound of a car speeding away.

Cruz went outside and heard a woman wailing, “My son! My son! My son!” and saw the boy lying on his side in the driveway behind a store at Margaret and Torresdale. Cruz said a man was trying to apply pressure with his hands to the boy’s neck but blood was “gushing everywhere.” Cruz said she called 911 and then grabbed someone’s hoodie, which she and the man then held against the boy’s wound.

She said the boy, dressed in his school uniform and wearing a backpack, was still conscious and complained, “My head hurts, my head hurts, get off me, get off me.” Cruz said she took that as a good sign because she wanted him to stay awake and keep talking. The boy tried to roll onto his back, but Cruz kept him on his side, she said.

A police SUV then arrived and two officers took the boy to the hospital. When they lifted him off the ground, Cruz saw what appeared to be a toy walkie-talkie that the boy collapsed on when he was shot.

Hours later, during an interview, Cruz was still shaken. She described her actions as a combination of instincts from her medical training and from being a mother.

Hokala said that the boy’s mother had been active with her Poor People’s Economic Human Rights Campaign for 17 years and that the boy also had been active recently.

Wednesday night, several congregants from the nearby Faith Assembly of God church at 1926 Margaret were outside the boy’s house singing and praying.

Last month, two children — one 11 months old, the other 2 years old — were shot days apart in Hunting Park and Kensington, allegedly by men who had wielded the same AK-47 in separate drug-related disputes, targeting adults.

Two other homicides last month also claimed the lives of children.

On Oct. 14 in Tacony, police have said, Damyrra Jones fatally shot her daughters, Maxillie Alcindor, 4 years old, and Damaya Alcindor, 10 months old, as well as her husband, Max Alcindor. Jones also shot herself but survived. She has been charged with three counts of murder and related offenses.

Two weeks later, inside a West Philadelphia home, 7-year-old Leslie Woodson-Holmes was one of four family members killed by 29-year-old Maurice Louis, authorities said. Police have said that Louis confessed to the killings. He has been charged with four counts of murder and related offenses.

Staff photographers Tyger Williams and Elizabeth Robertson contributed to this article.