Firefighters said at least one person had been killed in the collapse and that there could be more.
Warning: Video below shows collapse
The building, a former federal police headquarters, caught fire around 1:30 a.m. local time. Firefighters set up a perimeter and worked to evacuate people.
A few hours later, as flames engulfed the building, which was at least 20 stories, it collapsed. Globo TV, which was covering the fire, captured the destruction. Images showed the floors falling on themselves like dominoes and debris flying in all directions.
Romulo de Souza, 49, said he was part of a squatter occupation in the neighboring building. He said that when the fire began on the fourth floor, families began evacuating.
"Happily the majority got out," he said.
De Souza said that residents believed the fire could have been started by a gas leak.
Firefighter Lt. Andre Elias told Globo TV that at least one person had been killed in the collapse. Authorities were working to locate several others who were missing.
Clearing debris and accounting for people who had been in the building could likely take days. Several hours after the collapse, smoldering debris continued to emit smoke.
The fire and collapse are sure to put a spotlight on occupations in Sao Paulo, South America's largest city. Several dozen buildings have been occupied in downtown by highly organized fair-housing groups that take over and then fight for ownership. Many such dwellings are run like regular apartment buildings, with doormen and residents paying monthly fees and utility bills. Others are less established and more precarious.
In a June 2017 story on the occupations , The Associated Press reported that around 350 families were living in the former police headquarters. Local media on Tuesday reported that around 50 were currently living there.
Former Sao Paulo mayor Joao Doria, who recently stepped down to run for governor, cracked down on squatter communities as a plan to revitalize the downtown area.
Doria argued downtown Sao Paulo should showcase the city, the engine of Brazil's economy and one of the hemisphere's most important financial centers. Fair-housing activists, on the other hand, argue that the area could offer affordable housing to tens of thousands of people.