The attack was reported around 1 a.m. and involved a cab driver who had picked up three people near 18th and Valencia streets, according to police.
During the cab ride, the three passengers began arguing with each other, and then one of them, a 48-year-old man, began yelling at the driver and started choking him from the back seat, police said.
The driver pulled over and got out of the taxi, as did all three passengers. However, the 48-year-old man then got into the driver's seat of the car and tried to drive away but crashed into another car a block away, according to police.
The suspect, whose name has not been released, was detained by a bystander until police arrived to arrest him.
The 58-year-old taxi driver complained of neck pain and was taken to San Francisco General Hospital, police said.