Six buildings were affected by the fire, which started in the garage of a building at 4020 Mission St. The San Francisco Fire Department responded to the fire at around 5:50 a.m. The fire was under control at 7 a.m., a fire lieutenant said.
Twenty-six people, including three children, were displaced and will be staying in hotels tonight, American Red Cross spokeswoman Melanie Finke said.
Four apartments have been deemed uninhabitable and a fifth unit has a hole in its roof, Finke said.
"Anyone who can't get back into their homes will have a safe place tonight," Finke said.
San Francisco Animal Care and Control is at the scene to assist with the residents' pets, Finke said.
The cause of the fire remains under investigation.