A fire at an oil storage facility in the San Francisco Bay Area prompted a hazardous materials emergency Tuesday afternoon that led authorities to order about 12,000 people in two communities to stay inside with all windows and doors closed.

Thick plumes of black smoke and flames filled the skyline around the NuStar Energy LP facility in Crockett, California, about 30 miles (50 kilometers) northeast of San Francisco.

"This is a very dynamic, rapidly evolving situation," said Capt. George Laing of the Contra Costa Fire Department. "We've got two tanks that are releasing chemicals that are still burning."

A tank burns as fire breaks out at a refinery in Crockett, Calif., on Tuesday, Oct. 15, 2019. A fire burning at an oil storage facility in the San Francisco Bay Area prompted a hazardous materials emergency that led authorities to order the residents of two communities to shelter in place and stay inside with all windows and doors closed. Contra Costa Fire Department spokesman Steve Hill said that an hour into battling the blaze, firefighters seemed to be making progress and were continuing to keep adjacent tanks cooled with water. (Anda ChuSan Jose Mercury News via AP)

A tank burns as fire breaks out at a refinery in Crockett, Calif., on Tuesday, Oct. 15, 2019. A fire burning at an oil storage facility in the San Francisco Bay Area prompted a hazardous materials emergency that led authorities to order the residents of two communities to shelter in place and stay inside with all windows and doors closed. Contra Costa Fire Department spokesman Steve Hill said that an hour into battling the blaze, firefighters seemed to be making progress and were continuing to keep adjacent tanks cooled with water. (Anda ChuSan Jose Mercury News via AP)

The Contra Costa Health Department posted on Twitter that there was a "hazardous materials emergency" in the towns of Crockett, home to about 3,100 people, and Rodeo, population 8,700. The department urged residents to stay inside and close all windows and doors.

"Cover any cracks around doors or windows with tape or damp towels. Stay off the phone unless you need to report a life-threatening emergency at your location."

The city of Vallejo also tweeted that its residents should stay inside.

Contra Costa Fire Department spokesman Steve Hill said that an hour into battling the blaze, which started around 2 p.m., firefighters seemed to be making progress and were keeping adjacent tanks cooled with water.

Interstate 80 was closed.

Officials said they did not immediately know the cause of the fire and whether there was any connection to a 4.5-magnitude earthquake Monday night centered in the East Bay city of Pleasant Hill, north of Oakland.

That quake caused malfunctions at two nearby oil refineries operated by Shell and Marathon oil, Randy Sawyer, Contra Costa County's chief environmental health and hazardous materials officer, told KQED News. Some equipment at the Shell refinery was temporarily affected by the quake, spokesman Ray Fisher said.