Rescue teams worked through the night to pull out survivors after a massive explosion at the main headquarters of Mexico's state-owned oil company killed 32 people and injured 101.

Many casualties remained trapped in the rubble yesterday, as soldiers with rescue dogs, lorries with mounted lights and a crane were brought in to help.

The blast wrecked the basement and two floors of the Petroleos Mexicanos, or Pemex, building in Mexico City and sent hundreds fleeing into the street.

The Interior Ministry said it was unsure of the exact number trapped as many were outside having lunch when the explosion happened at about 3.45pm local time in a basement parking garage next to the famous 51-storey tower of Petroleos Mexicanos, or Pemex, one of the tallest buildings in Mexico City.

"It was an explosion, a shock, the lights went out and suddenly there was a lot of debris," employee Cristian Obele said, adding that he had been injured in the leg. "Co-workers helped us get out of the building."

President Enrique Pena Nieto said authorities had not yet found what caused the blast in the 14-storey building in a busy commercial and residential area.

Pemex chief executive Emilio Lozoya said: "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 first said it had evacuated the building because of a problem with the electrical system.