Updated

A huge explosion rocked Venezuela's biggest oil refinery and unleashed a ferocious fire on Saturday, killing at least 39 people and injuring more than 80 others in one of the deadliest disasters ever to hit the country's key oil industry.

Balls of fire rose over the Amuay refinery, among the largest in the world, in video posted on the Internet by people who were nearby at the time. Government officials pledged to restart the refinery within two days and said the country has plenty of fuel supplies on hand to meet domestic needs as well as its export commitments.

The explosion shattered walls of nearby shops, ripped out windows from homes and left the surrounding streets covered with rubble and twisted scraps of metal.

President Hugo Chavez declared three days of mourning and ordered an investigation to determine the cause of the explosion. "This affects all of us," Chavez said by phone on state television. "It's very sad, very painful."

Vice President Elias Jaua, who traveled to the area in western Venezuela, said on state television late Saturday that at least 39 people were killed by the explosion, up from the earlier death toll of 26. He said that the dead included 18 National Guard troops and that six of the bodies had not yet been identified. Other officials said earlier that the dead included a 10-year-old boy.

In a neighborhood next to the refinery, shopkeeper Yolimar Romero said she was at her computer when a shock wave swept over the area shortly after 1 a.m.

"At that instant, the whole house shook as if it were an earthquake," she said. "The windows went flying off with their frames and everything."

Electricity was knocked out, leaving Romero in the dark and her house filled with smoke. She found a flashlight and started looking for her husband and three children.

Outside on the street, the family saw scattered hunks of brick walls and ruins of a National Guard post and about 20 other homes. Bodies were being pulled from buildings down the street.

At least 86 people were injured, nine of them seriously, Health Minister Eugenia Sader said at a hospital where the wounded were taken. She said 77 people suffered light injuries and were released.

Flames reaching nearly 100 feet into the night air still crackled almost 20 hours after the explosion occurred, giving off searing heat felt by the residents of the neighborhood located approximately 1,000 feet from the refinery.

"This does not seem to be getting any better, I see and feel more and more flames," said Francisco Rojas, a 29-year-old taxi driver from the neighborhood as he loaded some of his belongings into a truck.

"I have a young daughter and my wife, and we don't want to take the risk of dying here," Rojas added.

Officials said firefighters had largely controlled the fire at the refinery on the Paraguana Peninsula, where flames were still visible on Saturday night after billowing dark smoke all day.

The blast occurred about 1:15 a.m. when a natural gas leak created a cloud that ignited, Oil Minister Rafael Ramirez said.

"That gas generated a cloud that later exploded and has caused fires in at least two tanks of the refinery and surrounding areas," Ramirez said.

Images shortly after the explosion showed the flames casting an orange glow against the night sky, and injured survivors on a stretcher and in a wheelchair. The bloodied bodies of victims were loaded onto pickup trucks.

Ramirez said a panel of investigators was being formed to determine the cause of the gas leak. A prosecutor was appointed to lead the investigation and troops were deployed to the area.

While the cause of the disaster remains unclear, some oil workers and critics of Chavez's government have recently pointed to increasing numbers of smaller accidents and spills as an indication of problems within the state-run company.

"We warned that something was going to happen, a catastrophic event," said Ivan Freites, secretary general of a 1,200-member union of oil and natural gas industry workers in Falcon state where the refinery is located. He spoke in a telephone interview from an area near the refinery, where he could see the flames raging in the distance.

The refinery complex's general manager, Jesus Luongo, denied that a lack of maintenance was to blame, saying in the past three years more than $6 billion has been invested in maintaining the country's refineries.

Ramirez said the explosion hit an area of storage tanks, damaging nine tanks.

"All of the events happened very quickly," Ramirez said. "When we got here in the middle of the night, at 3 or 3:30 in the morning, the fire was at its peak."

The oil minister said that supplies of fuel had been cut off to part of the refinery and that firefighters were using foam to extinguish the flames in one of the remaining tanks.

"This regrettable and sad event is controlled, is under control," Ramirez said on television, while plumes of smoke continued to billow.

Amuay is part of the Paraguana Refinery Complex, which also includes the adjacent Cardon refinery. Together, the two refineries process about 900,000 barrels of crude per day and 200,000 barrels of gasoline. Venezuela is a major supplier of oil to the U.S. and a member of the Organization of Petroleum Exporting Countries.

Ramirez said the state oil company Petroleos de Venezuela SA should be able to "restart operations in a maximum of two days."

"We want to tell the country that we have sufficient inventories of fuel. We have 10 days of inventory of fuel," Ramirez said. He said the country's other refineries were operating at full capacity and would be able to "deal with any situation in our domestic market."

An official of the state oil company, known as PDVSA, said the country also has enough supplies on hand to guarantee its international supply commitments. The official spoke on condition of anonymity because he wasn't authorized to speak publicly about the matter.

In terms of international oil markets, the disaster is not likely to cause much of a ripple, said Jason Schenker, an energy analyst and president of Austin, Texas-based Prestige Economics LLC. Noting that other refinery accidents and shutdowns regularly occur around the world, he said: "There's likely to be relatively limited impact on global crude or product pricing."

"The real tragedy," he said, "is that these events continue to happen, not just in Venezuela but everywhere. It is a dangerous business."

Gustavo Coronel, an energy consultant and former PDVSA executive, called the tragedy "probably the worst one the oil industry has had in many years."

"Accidents happen, of course, although the problem with PDVSA is the inordinate amount of accidents that have taken place during the last years," Coronel said. Considering the overall record, "we are not talking about bad luck but about lack of maintenance and inept management," he said.

The labor leader Freites, who has worked at the refinery for 29 years, said workers had repeatedly alerted state oil company officials to problems that they feared could lead to an accident. "We've been complaining about problems and risks, including fires, broken pipes and a lack of spare parts," Freites said.

One opposition group comprised of former PDVSA employees, Gente del Petroleo, or Oil People, said it could not yet pass judgment on the cause of the explosion. But it but noted there had been ample concerns about lack of maintenance and poor management.

The group said in a statement that since 2003, 79 other serious accidents have been reported at the Paraguana Refinery Complex, collectively killing a total of 19 workers and injuring 67 others.

Opposition leader Henrique Capriles, who is challenging Chavez in the country's Oct. 7 presidential election, expressed condolences to the victims and their families.

"We Venezuelans are one, and we grow in the face of this type of situations," Capriles said.

____

Jorge Rueda reported from Punto Fijo and Ian James reported from Caracas. Associated Press writers Christopher Toothaker and Fabiola Sanchez also contributed to this report from Caracas.

____

Ian James on Twitter: http://twitter.com/ianjamesap