Two women were killed and a man was wounded on Friday before a suspect covered in blood was arrested in SoMa, authorities said.
Investigators were trying to determine if the shooting was connected to a botched robbery.
Responding officers encountered the suspect outside the San Francisco Giftcenter & Jewelrymart in SoMa.
The man, whose name was not released, opened fire at officers while retreating into a restaurant, police Chief Greg Suhr said. The man kept shooting until he apparently ran out of ammunition and surrendered, Suhr said.
Officers did not return fire because the sidewalks were crowded with shoppers and residents. Employees of nearby businesses, including REI and Zynga, were ordered to shelter in place during the search.
After the arrest, officers went inside the shopping center and found the two women dead in the lobby.
Another man with unknown injuries was taken to a hospital in stable condition.
Officers were interviewing witnesses who ducked for cover when the shooting began.
“Somebody was crying or yelling for help. Then I saw the SWAT. There was a dozen of them. They told us to lock ourselves in,” Veronica Sirois, who was shopping at the gift center, told the San Francisco Chronicle. “I saw blood on the way out and a pair of bodies.” A “shelter in place” has been established between Sixth and Ninth and Brannan and Townsend Streets.