There are fears the death toll will rise once a fire near an oil refinery in central Mexico is extinguished.
Hidalgo's governor Omar Fayad told Mexican television that emergency services had registered the charred bodies of 21 people, and that at least 71 others had been injured. However, the blaze had yet to be extinguished, he said.
"There's still a very hot area where we think the number of injured or dead we haven't had access to could rise," he said.
Television footage showed flames leaping into the night sky in the town of Tlahuelilpan, near the Tula oil refinery.
A pipeline was ruptured by suspected fuel thieves and dozens of people tried to fill up containers, state and federal authorities said.
Local residents were scrambling to steal some of the leaking oil when they were engulfed in flames, said Mr Fayad.
Dozens of people have been taken to hospitals with burns.
Images published on broadcaster Televisa showed people with severe burns from the blast as the government sent in ambulances and doctors to treat the victims.
Mr Fayad later flew in a helicopter over the disaster area and promised to help residents.
"I urge the entire population not to be complicit in fuel theft," Mr Fayad said on Twitter. "Apart from being illegal, it puts your life and those of your families at risk."
The Tula refinery is owned by the state oil firm Petroleos Mexicanos (Pemex), which in a statement blamed the incident on an illegal tap.
However, Pemex has suffered a number of accidents in the past. At least 37 people were killed in an explosion at its Mexico City headquarters in 2013 and another 26 died in a fire at a gas facility in 2012.
Mexican President Andres Manuel Lopez Obrador has launched a major crackdown on rampant fuel theft, which the government said cost the country more than $US 3 billion ($NZ4.4b) last year.
Mr Lopez Obrador expressed his concern on Twitter, and said he wanted "the entire government" to help people at the scene.
The president's crackdown on theft has significant public backing, though his decision to turn off pipelines to thwart the thieves disrupted the fuel supply in central Mexico and raised concern that the shortages could damage the economy.
Some users of social media responded to the explosion with anger, saying the fuel thieves only had themselves to blame.
- Reuters / BBC