One firefighter sustained minor injuries and officials say the Red Cross is assisting 50 people who were displaced by the fire.
A total of five buildings were damaged. Officials say the main building that caught on fire is red tagged and no one is allowed to go inside.
The blaze was reported at 12:34 p.m. at a two-story, dark green building at 1448/1450 Valencia St., between 25th and 26th streets.
The flames spread to the attic space of the EHS Pilates studio next door and a four-plex at 1442/1446 Valencia St., fire department spokeswoman Mindy Talmadge said.
A fourth building on Poplar Street, an alleyway that runs parallel to Valencia, was also damaged, Talmadge said.
Crews controlled the fire at 1:55 p.m. No injuries were reported.
Valencia Street remained closed between Cesar Chavez and 25th Street as of 2:25 p.m.
Kerri Myers said she was teaching a class at the studio, EHS Pilates, when she hard a banging sound coming from the back of the building along Poplar Street.
She looked out the window and saw flames, and everyone in the studio fled the building, she said.
Denise Hunley, a graduate student in clinical psychology who lives across the street, said she was sitting at her desk doing some work when she smelled smoke.
When she looked outside, she saw flames coming from the roof of the green building and watched several startled-looking people being evacuated. Hunley said she worried that there were elderly people or animals still inside the building.
She also noticed debris and embers from the fire floating across the street toward her house, and called her roommates to see if they had any important papers she should save if their home caught fire.
"I didn't know how bad it was going to be," said Hunley, who moved to San Francisco a couple of months ago from Chicago.
abc7news.com contributed to this story.