The incident was reported at about 5:25 p.m. near the intersection of Grant Avenue and Edgardo Place.
A man was backing his car out of the driveway when a witness nearby yelled at him to stop because someone was under the vehicle, according to police.
The man got out of the car and saw that it had rolled over the boy, who suffered a serious head injury, police said.
The boy was taken to San Francisco General Hospital.
The man cooperated with investigators, police spokesman Officer Albie Esparza said.