The shooting was reported at 11:29 a.m. on Aug. 11 in the 1000 block of Oakdale Avenue.
The 20-year-old victim was approached by three suspects, one of whom pulled out a black semiautomatic gun from his waistband and shot at him, according to police.
The victim tried to flee but a bullet ricocheted and struck him in the foot, police said.
He was taken to San Francisco General Hospital to be treated for the injury, which was not life-threatening.
The motive for the shooting appears to simply be that the victim was not from the suspects' neighborhood, police said.
The suspects fled, but the Police Department's gang task force was eventually able to identify the suspected shooter and obtain a warrant for his arrest.
On Sunday, the suspect was spotted in the driver's seat of a car parked near Revere Avenue and Hawes Street, according to police.
He was arrested on suspicion of attempted murder. The teen's name is not being released because he is a juvenile, police said.
Anyone with additional information about the shooting is encouraged to call the Police Department's anonymous tip line at (415) 575-4444 or send a tip by text message to TIP411.