The robbery occurred at about 4:10 a.m. on July 10 near the intersection of Grove and Lyon streets in the city's North of Panhandle neighborhood.
The 66-year-old cabbie had picked up three men, and one demanded money from him, according to police.
The suspects searched the driver and took cash from him. Two of the men then hit him in the head with their handguns, then all three got out of the cab and fled, police said.
The cabbie was not seriously injured in the attack.
At about 10:35 p.m. Friday, an officer from the Park Police Station spotted a man near Haight Street and Masonic Avenue and recognized him from an image taken by the cab's surveillance system.
The officer detained the man, a 19-year-old Treasure Island resident, and a sergeant also responded to the scene to question him, police said.
He briefly ran away from police during the interview but was arrested near Fell and Ashbury streets after a short chase, police said.
His name has not yet been released.