The girl was walking with her father near the intersection of Third Street and Palou Avenue when she was struck in the left knee. The father was not hit.
The girl spent the night at the hospital, but her injuries are not life-threatening.
"I ran for my life because I'm hearing gunshots. So I ran behind the counter and when I came out, we looked up the street and I saw everybody running and I saw the little girl on the ground and I saw her father pick her up and you know, he was very distraught and he was upset," said witness Kilo G. Perry.
When the shooting was over, at least four shell casings littered the street. The girl was walking home from school with her father around 4:30 p.m. when he heard gunshots.
"He noticed his 5-year-old daughter fall to the ground. At first he thought she just may have fallen, tripped or something like that, then he noticed that she was shot in the knee," said San Francisco Lt. Troy Dangerfield.
The man carried the girl a few blocks and then flagged down a police officer. She was rushed to San Francisco General Hospital by ambulance.
"Well, I heard that she is stabilized, she is doing well. Her spirits are up. I heard that she was shot in her knee and she's already convinced her mother that she's out of school for the rest of the week," said San Francisco Supervisor Malia Cohen.
A police source tells ABC7 News that a 22-year-old man walking near the corner opened fire on another man who then shot back. They believe the return fire struck the girl. This is the same area where police and a Muni fare jumper were involved in a shootout in July.
"There's an unacceptable tolerance for violence. It's not OK to open fire anywhere and I'm really hopeful that this particular case will resonate with moms and dads and just people in the Bayview community to drive home the message that it's not OK to open up fire," said Cohen.
Some neighbors blame the violence on the abundance of liquor stores and drugs in the area.
"This is where everybody comes where the city is not treating this neighborhood right is the problem out here," Willie Ratcliff, editor of the Bayview Newspaper.
Police say they have surveillance video that may point to the two shooters and one of them may already be known to police. Police say there are witnesses out there and they would like them to contact the police department. Investigators are still trying to figure out is this is gang related.
If you have a tip for police, you can call the Bayview investigation team at (415) 671-2363, the anonymous tip line at (415) 575-4444 or text a tip to TIP411.