(Reuters) - Flames engulfed two ethanol holding tanks on Tuesday at a NuStar Energy petrochemical storage facility near San Francisco, prompting health authorities to urge residents of two adjacent towns to remain indoors for much of the day while crews battled to subdue the blaze.

No injuries were reported from the fire, which began shortly before 2 p.m. (2100 GMT) and spread to a large grassy field just outside the tank farm in the waterfront community of Crockett, California, about 30 miles northeast of San Francisco.

Local media reported an explosion that shook buildings and rattled windows for miles around and sent a fireball into the air. Some residents thought it was an earthquake, the San Francisco Chronicle newspaper reported.

The fire was declared contained by about 9 p.m., fire officials said on Twitter, but they were still working to prevent it from spreading to other tanks.

Initial reports that flames had spread to a third tank proved erroneous, Contra Costa County Fire Department spokesman, Steve Hill, told reporters at a news conference. He said the grass fires scorched about 15 acres around the facility before they were mostly extinguished.

One of the two burning storage tanks collapsed from the blaze, spilling some of its contents into a secondary containment area and raising the threat of flames spreading to nearby structures, Hill said.

Of greatest immediate concern were three additional storage tanks, each holding either ethanol or jet fuel, and crews continually doused them with water to cool them and prevent further combustion, Hill said.

Firefighters, meanwhile, poured flame-retardant foam onto the burning tanks to smother the flames. The blaze appeared to die down at one point, only to flare up when the foam cap was disturbed by winds.

Hill said crews aimed to keep the fire confined to the NuStar property, located a short distance from a Phillips 66 refinery in nearby Rodeo, California.

Interstate 80, a highway running past the tank farm, had been closed to traffic in both directions for much of the day, but was reopened about 9:30 p.m., Hill said.

“It’s still a fluid situation,” Hill said. “There have been a number of flare-ups.”

Health authorities monitoring air quality in the area issued advisories urging residents of Crockett and Rodeo to remain indoors with windows closed to limit their exposure to soot and smoke from the fire for about 8 hours. The order was lifted about 10 p.m., fire officials said.

Between 12 and 20 residents of another nearby community, Tormey, were evacuated as a precaution, officials said.

NuStar said the burning tanks had been filled to less than 1% of their capacity. One contained 167,000 gallons, or about 4,000 barrels, of ethanol, an alcohol that federal rules require be added to gasoline to reduce pollution.

Hill said the cause of the blaze was under investigation.

It was unknown whether the fire was related to a small earthquake on Monday night that disrupted operations at two nearby oil refineries in Martinez, California.