A series of explosions and a spectacular fire ripped through a South Philadelphia oil refinery early Friday, rattling windows, injuring workers, unnerving the city, and causing gasoline markets to spike on speculation of fuel shortages.

The incident at Philadelphia Energy Solutions , the East Coast’s largest refinery, injured five workers, who were treated at the scene. The fire was still burning Friday night.

Safety advocates said the danger could have been far worse had the blast released a cloud of hydrogen fluoride, a deadly chemical used in the refining process.

The U.S. Chemical Safety and Hazard Investigation Board, an independent federal agency, announced Friday that it was dispatching a four-person team to Philadelphia to investigate the incident, which was similar to refinery accidents in Torrance, Calif., in 2015 and Superior, Wis., last year that came perilously close to releasing hydrogen fluoride. The Wisconsin accident prompted a temporary evacuation of residents.

“Philadelphia and surrounding communities appear to have narrowly dodged a catastrophe this morning,” Joseph Otis Minott, executive director of the Clean Air Council, said in a letter calling for the CSB to investigate.

PES said three explosions “impacted” a unit that produces alkylate, used to boost gasoline octane. The refinery complex has two alkylation units, and the unit that was involved in the conflagration uses hydrogen fluoride — also known as hydrofluoric acid — as a catalyst. A 2009 release of just 22 pounds of the chemical at the South Philadelphia refinery sent 13 contract workers to the hospital.

“Hydrogen fluoride is extraordinarily dangerous,” said Fred Millar, an Arlington, Va.-based chemical disaster expert and independent consultant. City officials said none of the material was released in Friday’s event.

The incident, about 4 a.m. Friday, lit up the predawn sky with a fireball so large that it was captured by a weather satellite. City health department spokesperson James Garrow said the city took air quality samples both upwind and downwind of the refinery. The samples were taken to the city’s Air Management Services Laboratory and were tested for 61 chemical compounds, none of which was found to be at “or even near” harmful levels.

PES refining complex firefighters responded initially and were supported by city firefighters, said Deputy Fire Commissioner Craig Murphy. The fire quickly escalated to a third alarm.

Murphy said the firefighters contained the fire to the alkylation unit, and cooled surrounding pipes and tanks with water. He said 120 Philadelphia firefighters and 51 pieces of equipment were involved in the operation.

“It is standard practice when fighting a fire of this type to let the flammable gases burn away in a controlled fashion,” Fire Commissioner Adam Thiel said.

The cause of the explosions is not known. The Fire Marshal’s Office will investigate once the scene is safe to enter, Thiel said.

The fire originated in a propane tank, said Cosmo Servidio, mid-Atlantic head of the U.S. Environmental Protection Agency, adding that “no other tanks were affected.”

“We have not determined the product that was burning, but we believe it was mostly propane,” PES said in a statement. Earlier in the day, Murphy said butane was thought to be feeding the fire.

Officials lifted a shelter-in-place request for residents in the immediate area and reopened the George C. Platt Memorial Bridge, which was closed after the explosions.

“Those who live and work in close proximity to the refinery and all Philadelphians have our word – we are firmly committed to ensuring the safe operation of the refinery and the safety of those in its vicinity,” Mayor Jim Kenney said in a statement.

Wholesale gasoline prices surged 3.7 percent Friday in New York on speculation that the PES outage might curtail regional fuel supplies.

But Tom Kloza, global head of energy analysis for the Oil Price Information Service, said the uptick was unlikely to last long, as Northeastern fuel markets are supplied from multiple sources, including refineries on the Gulf Coast, and in Canada and Europe.

“The North Atlantic market has plenty of gas,” he said.

PES can process 335,000 barrels of crude oil a day, or about 14 million gallons. It employs about 1,000 people.

The company said the refining complex was running at a reduced rate.

The refinery emerged from bankruptcy last year but has continued to struggle under a heavy debt and intense competitive pressures. Its management team has been reshuffled in recent months.

Refineries convert crude oil to a range of petroleum products, including gasoline, diesel fuel, and heating oil, through a number of process units that operate under high pressure and heat. They are inherently hazardous.

The refinery was the scene of a smaller fire that PES said was quickly contained on June 10. There were no injuries in that incident.

Kenney said in a statement that he spoke Friday with PES leadership, as well as the Fire Department and Managing Director’s Office, and “was assured that the two incidents are unrelated in their nature and cause,” and was informed of the speed with which notifications went to nearby residents.

“Still, I believe that there is room for improvement, both in the operation of the refinery in light of two fires in as many weeks, and in the communication to residents,” he said.

Two incidents in the same month prompted activists to call for the refinery’s closure and to convert the 1,300-acre site to public land and community-owned energy projects.

“What happened this morning in our city was an absolute travesty and outrage,” City Councilwoman Helen Gym said at an afternoon news conference, standing with members of Philly Thrive, a South Philadelphia organization that blames the refinery for neighborhood health problems.

The explosion “puts it all on us to do something,” Gym said, adding that city leaders “cannot wait another day” to begin moving the refinery toward eventual transition.

A University of Pennsylvania report in September warned that the financially troubled South Philadelphia refinery complex may be shut down in the next few years and that the city should prepare to deal with an industrial property fouled by more than a century of fuel production.

Independent refiners like PES have been under fierce competitive pressure, which intensified recently when the EPA approved sales of gasoline containing 15 percent ethanol year-round instead of just eight months a year. Oil refiners say the ethanol mandate increases their costs.

The EPA worked with the state and city to set up “fence line” air monitors “along the perimeter” of the refinery and possibly in the community to keep a check on air quality, Servidio said.

Monitoring produced normal readings for explosives, carbon monoxide, oxygen, and hydrogen sulfide, a dangerous gas, the company said.

“The health department has no findings that would point to any immediate danger in the surrounding community at this time, and the city is not recommending evacuation or shelter-in-place,” Garrow said in a statement.