The fire broke out just before noon in Taqueria El Castillito, a ground-floor, Mexican restaurant on Golden Gate Avenue near Larkin Street.
Nobody was hurt. Police officers on routine patrol noticed heavy smoke rising from the building.
"We were just sitting watching TV and heard the sirens and we heard the police in the hallway yelling, get out, get out!" said building resident Mike Moore.
SFFD Assistant Chief Kevin Burke added, "The police reported this fire, they saw it first, so kudos to the police department. They do a great job, and they helped us out here too."
Smoke, flames, and water damaged at least eight apartments in the five-story building.
The Red Cross is helping the residents of those units find places to stay for the time being.