The fire was reported shortly after 5 a.m. at a three-story building at 41-43 Barcelona Ave., in the area of Geary Boulevard and Masonic Avenue.
Firefighters arrived to find flames coming through the building's roof and called for a second alarm, fire Lt. Mindy Talmadge said.
Investigators believe the fire started on a lower level, Talmadge said. She said the structure is a "soft-story" building, meaning the ground floor consists mostly of garage space, but that there is also an in-law unit on that floor.
The fire was intensified by flames burning behind metal sheeting that lines a light well, she said. Additionally, the fire was concentrated in the rear of the building, which made it difficult to combat.
"It was a little challenging getting to that area," Talmadge said.
The blaze went to three alarms and spread to a two-story apartment building next door before firefighters were able to control it shortly before 6:30 a.m., she said.
No injuries were reported, but 15 people were displaced, she said.
The American Red Cross was called in to assist the affected residents and has provided shelter to five residents, Talmadge said. The others were able to find a place to stay.
The cause of the fire remains under investigation, and investigators are working to assess the damage.