(Reuters) - An explosion and fire ripped through a gasoline processing unit at an Exxon Mobil refinery in Torrance, Calif., near Los Angeles on Wednesday, slightly injuring four workers and shattering windows of surrounding buildings, authorities said.

The cause of the blast, shortly before 9 a.m. PST, was under investigation, but there was no evidence of foul play, said Torrance Fire Captain Steve Deuel.

"All personnel have been accounted for," Exxon said in a statement. "Four contractors have been taken to Long Beach Medical Center for evaluation for minor injuries."

Torrance Mayor Patrick Furey told local television station KNBC in an interview that people who live near the refinery should take precautions.

"The most important thing is to shelter in place, stay indoors, no outdoor activity, turn the air conditioners off, keep the windows closed," Furey told the station.

Cory Milsap, an electrical contractor at the plant, said many workers were sent home after the explosion.

"All I heard was a loud sound and I saw people running." ... "All I saw was smoke and people running, so I made sure I got out of there," Milsap said.

Jason Hernandez, another plant employee, said, "I felt the explosion really, really hard through my body. I got scared, I'm not going to lie."

Giselle Monreal, a neighbor who lives across the street from the plant, said the blast shook the ground like an earthquake, knocking a 52 inch (132-cm) flat-screen television off its stand onto a coffee table and shattering a window in her garage.

Deuel said a small ground fire following the explosion was quickly extinguished. Firefighters and refinery crews also contained a gasoline leak caused by the blast, he said.

Surrounding areas were not evacuated, but nearby schools kept students and staff indoors immediately after the explosion as a precaution, Deuel said.

The fire captain said structural damage appeared to be confined to the processing unit that blew up but said the full extent of damage had yet to be ascertained.

"We're in the process of stabilizing the situation and there are no other issues happening," he told Reuters. Excess gasoline was being flared, or burned off, by the refinery, he added.

Students at 14 schools near the refinery were ordered to shelter in place because of concerns over air quality, meaning students would not be allowed outside, Torrance Unified School District spokeswoman Tammy Khan told Reuters.

The company was looking into the cause of the explosion, according to Gesuina Paras, a public and government affairs adviser at Exxon Mobil.

Trade publication OPIS, citing an unidentified source, reported that an electrostatic precipitator (ESP), which reduces fluid catalytic cracker particulates, exploded as contract workers were doing maintenance on the nearby fluid catalytic cracking unit, or FCC.

"Contractors working on the FCC to fix the expanders," the source said, adding that an injection of ammonia on top of the flue gas stream caused a pressure buildup, which resulted in the ESP unit explosion.

The unit could take up to a year to replace, the source said.

Exxon Mobil's shares extended morning losses after news of the blast before stabilizing. The shares were down 2.2 percent at $90.83 in late afternoon trading on the New York Stock Exchange.

TWISTED METAL, ASH

David Campbell, an official with the local chapter of the United Steelworkers union, which represents plant workers, also said the blast at the refinery occurred near the fluid catalytic cracking unit.

The plant, which occupies 750 acres (300 hectares), refines 155,000 barrels of crude oil per day, according to Exxon Mobil. Its workforce consists of 650 employees and 550 contractors.

Helicopter news footage on local television station KNBC showed a scene of twisted metal wreckage as firefighters poured streams of water on the refinery. A few vans were covered in ash and debris with their doors open.

Exxon had planned to overhaul the 100,000-barrel-per-day (bpd) gasoline-producing FCC at the refinery this month, said sources familiar with the refinery's plans.

If the plant is shut due to the explosion and fire, it will be the second California refinery to be closed. Tesoro's Martinez refinery is already shut.

News of the explosion jolted some energy markets. March-delivery CARBOB gasoline in the Los Angeles wholesale market jumped on news of the refinery fire, traders said.

Tesoro Corp shares rose more than 3.5 percent to $86.83. They have three California refineries and will benefit from the Torrance incident.

Torrance is a residential suburb about 20 miles (30 km) south of Los Angeles, which is also home to some industries. Toyota Motor Corp and Honda Motor Co Ltd have their North American operations bases there.

The city had a population of more than 147,000 in 2013, according to a U.S. Census Bureau estimate.

The incident came after the United Steelworkers walked out of 11 facilities, including nine refineries accounting for 13 percent of U.S. production capacity, after negotiations on a national contract stalled on Feb. 1. One of the central issues, according to the USW, is employee safety.

Torrance has not been part of the walkouts.

Striking U.S. refinery workers said on Wednesday that the Exxon blast underscores concerns the United Steelworkers has about safety standards at refineries and chemical plants nationwide.

(Reporting by Steve Gorman; Additional reporting by Alex Dobuzinskis and Steve Gorman; Writing Bernard Orr; Editing by Jonathan Oatis)