SAO PAULO -- A high-rise building occupied by squatters in downtown Sao Paulo caught fire and collapsed Tuesday, sending chunks of fiery debris crashing into neighbouring buildings and surrounding streets.

Firefighter Lt. Andre Elias told Globo TV that at least one person had been killed.

At the moment the building fell, a firefighter atop a neighbouring building had been trying to save someone from the upper floors. TV images showed the person clinging to the building's side, while apparently also attached to a rope that the firefighter was holding. Then the wall the person was clinging to started to fall away, taking the person with it. The floors of the burning building collapsed like dominoes, while debris flew in all directions, and a giant fireball briefly filled the street.

Authorities later said that the person killed was the one the firefighter had been trying to save, and a body had not yet been found. Firefighters were using dogs to search for that person and any others in the rubble.

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.

Less than two hours later, the 25-floor building collapsed while Brazilian media were filming. No firefighters were hurt.

By late Tuesday morning, several families who had fled were camping out in front of a nearby church, where neighbours and local businesses were dropping off supplies including bags of bread, milk, bottles of water and even some used clothing and shoes.

Lohany Michely, 37, said she was asleep with her boyfriend and dog in their apartment on the third floor of the building when she began hearing people outside yell about a fire. Seeing smoke, the couple left with their dog, then watched the building collapse about 45 minutes later.

"Entire families lost everything," she said. "People think that people who live in an occupation are animals. We are not animals. We are human beings."

Romulo de Souza, 49, said he was part of a squatter occupation in the neighbouring building. He said he watched families evacuating.

"Happily the majority got out," he said, adding that residents believed the fire could have been started by a gas leak.

Clearing debris and accounting for people who had been inside could take days. Several hours after the collapse, smouldering debris continued to emit large plumes of smoke.

The fire also burned part of a neighbouring building, and authorities said three surrounding structures were evacuated as a precaution.

The fire was in an area known as "Centro," which is Sao Paulo's historic downtown. It began emptying out in the 1970s and 1908s after several fires broke out and another business district developed. These days, the neighbourhood is on the cusp of a comeback and is equal parts dilapidated and edgy. Several city administrations have led campaigns aimed at beautifying and redeveloping the area, which now hosts most of the city's homeless and has numerous blocks occupied by crack addicts.

The fire is sure to put a spotlight on the occupations, which are led 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. Others are less established and more precarious.

In a July 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 between 50 and 150 were currently living there, underscoring the sometimes fluid nature of such makeshift dwellings.

"It's a building that didn't have the most minimal conditions to live in," Sao Paulo Gov. Marcio Franca, who visited the site, told news site UOL, adding that "the occupation should never have been allowed."

Junior Rocha, who is a co-ordinator for an organization that runs three downtown occupations, said the group takes precautions to avoid tragedies by annually changing the cable that brings electricity to buildings, placing extinguishers on every floor and telling residents to evacuate if they have the smallest doubt there is a problem.

But the buildings are old, and Rocha said the residents themselves are the ones who try to maintain them.

The authorities "are going to use this as a way to pressure our movements to leave these buildings," he said. "The state is acting as if us, the occupiers, us, from the movements, are responsible for this. We're not responsible, the system is at fault."

Former Sao Paulo mayor Joao Doria, who recently stepped down to run for governor, cracked down on squatter communities as part of a plan to revitalize the downtown area.

Doria argued the downtown should be a showcase for South America's largest city, the engine of Brazil's economy and one of the hemisphere's most important financial centres. Fair-housing activists, on the other hand, argue that the area could offer affordable housing to tens of thousands of people.

During a brief visit to the area Tuesday, President Michel Temer told reporters that the government would help those affected by the fire.

"We will provide assistance to the victims of this disaster," said Temer, who has been charged with corruption and has approval ratings in the single digits. He did not provide details and was whisked away by security as several people shouted obscenities at him.

Peter Prengaman reported from Rio de Janeiro. AP photographer Andre Penner contributed to this report from Sao Paulo.