Mexico's government has vowed to find out whether an explosion that killed 33 people at the headquarters of its state-run oil company Pemex was a deliberate attack or an accident.

Government officials have refused to speculate over what caused the explosion that ripped through the annex of the firm's Mexico City skyscraper on Thursday.

"The government is determined to find the truth in this incident, whatever it is; whether it was an accident, whether it was carelessness, whether it was an attack," Attorney General Jesus Murillo Karam told reporters on Friday.

"We don't want to leave anything to the imagination," he said as rescuers wound down the search.

President Enrique Pena Nieto has declared three days of national mourning.

Parts of the reinforced concrete ground floor of the building caved in, and the ceiling was a mess of twisted metal pipes and ducts.

Speculation

Speculation over the cause has ranged from a bomb attack, to a gas leak, to a boiler blowing up.

"A fatal incident like yesterday's cannot be explained in two hours. We are working with the best teams in Mexico and from overseas. We will not speculate," Pemex's chief executive, Emilio Lozoya, said.

Investigators from the army, navy, federal police, prosecutor's office and two foreign firms were involved in the probe.

Hundreds of firefighters, police and soldiers aided by dogs dug through rubble for almost 24 hours straight, with the help of floodlights and cranes after the blast caused the mezzanine of the annex to collapse.

Thousands of people work in the Pemex complex, but officials said the area hit by the blast has four levels and housed 200 to 250 employees.

Mexican Red Cross coordinator Isaac Oxenhaut indicated that the mission to rescue survivors or search for bodies was over.

"We rule out there being any trapped victims," he said.