A fire ripped through a warehouse occupied by migrants near Barcelona killing at least two people and injuring 19, including several who jumped from the building to escape the flames, Spanish officials said Thursday.

The blaze broke out at around 9:00 pm (2000 GMT) on Wednesday in an industrial area of Badalona, a Barcelona suburb, where up to 200 migrants lived in squalid conditions, according to Badalona city hall.

Firefighters said they had so far found two bodies but could not rule out that more fatalities since they have not been able to enter the three-story building which had been occupied by squatters for years.

The blaze has been brought under control but firefighters were working to stabilise the structure of the warehouse to safely enter it and look for anyone who may be trapped inside, fire chief David Borrell told reporters at the scene.

"We are trying to determine if there are any sign that there are more people or not," he said.

At least 19 people were injured, including seven seriously, Catalonia's civil protection agency said in a tweet.

Some people were hurt after jumping from the building, regional health minister Alba Verges said.

Badalona mayor Xavier Garcia Albiol said the authorities had accounted for 60 people "but many escaped through the back windows and fled. Maybe more than one hundred people left."

Firefighters put out the fire in the Spanish warehouse where up to 200 migrants lived
Firefighters put out the fire in the Spanish warehouse where up to 200 migrants lived AFP / LLUIS GENE

Moises, a Moroccan man who lived in the warehouse told daily newspaper La Vanguardia the blaze was started by a candle but Catalonia regional interior minister Miquel Samper said the authorities were still investigating the cause of the blaze.

Catalonia's interim regional leader Pere Aragones said housing assistance would be offered to those who lived in the warehouse.

"This is a tragedy which comes on top of the economic misery which unfortunately many of the affected people faced," he said during an interview with Spanish public television TVE.

Most of the residents were reportedly from sub-Saharan Africa and lived by selling goods on the street or collecting scrap metal.

Prime Minister Pedro Sanchez said he was following the news "of the tragic fire in Badalona with concern."

"I am deeply sorry for the loss of human life and I am grateful for the great work of the emergency services, who have saved dozens of people from the flames," he said in a tweet.