The blast occurred about 1:15 a.m. when a gas leak created a cloud that ignited, officials said. An adjacent National Guard post was severely damaged by the blast, along with nearby homes, he said.
Officials said those killed included a 10-year-old boy, and that 17 of the 26 victims were National Guard troops stationed at the post next to the refinery.
Government officials pledged to restart the refinery within two days and said the country has plenty of fuel supplies on hand to meet its domestic needs as well as its export commitments.
President Hugo Chavez declared three days of mourning in the country and ordered a "deep investigation" to determine what caused the explosion.
"This affects all of us," Chavez said by phone on state television. "It's very sad, very painful."
While the cause of the disaster was unclear, some critics of President Chavez's government have recently pointed to increasing numbers of smaller accidents and spills as an indication of problems within the state-run company.
The Associated Press contributed to this report.