SAN FRANCISCO -- San Francisco fire investigators on Wednesday were looking into whether welding work was to blame for a huge blaze that tore through an apartment building construction site, threatening nearby buildings, prompting evacuations and forcing officials to call in about half the city's on-duty firefighters to prevent its spread.

As fire crews doused hotspots in the charred remains of the block-long apartment complex, city officials said they narrowly avoided a catastrophe in one of the city's largest fires in recent years.

"I think we're very lucky that the fire didn't jump anymore," Mayor Ed Lee said.

Two firefighters suffered minor injuries.

The exact cause of the fire was under investigation, but fire officials were looking into preliminary reports that workers were doing torch work at the site shortly before the fire was reported Tuesday evening, Fire Chief Joanne Hayes-White said.

The plume of black smoke was visible above the city skyline.

The fire was fueled by wood frames and other materials at the site, Hayes-White said. Since it was under construction, the building also had no fire suppression systems.

Fire officials did not have an exact estimate on the damage on Wednesday, but said the entire six-story building was considered a loss.