You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Mexican television footage showed flames leaping into the night sky in the municipality of Tlahuelilpan, in Hidalgo state north of Mexico City, as people screamed and cried for help.
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.
Fayad said the number of victims could still rise depending on what emergency services discovered where the blaze had been hottest, which had been difficult to access.
Shortly before midnight, Public Security Minister Alfonso Durazo said the fire had been put out, and that the government would need time to establish the final death toll.
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.
Mexican President Andres Manuel Lopez Obrador has launched a major crackdown on rampant fuel theft, which the government said cost the country more than $3 billion last year.
The explosion was one of the worst in recent history in a country that has suffered hundreds of illegal ruptures to its network of oil and gas pipelines.
The ruptured pipeline was near the Tula refinery of state oil firm Petroleos Mexicanos (Pemex), which in a statement blamed the incident on an illegal tap.
Separate television footage showed the pipeline gushing a fountain of fuel earlier in the day and dozens of people at the site trying to fill buckets and plastic containers.
Lopez Obrador expressed his concern on Twitter, and said he wanted "the entire government" to help people at the scene.
Separately, Pemex said on Friday evening it was also dealing with a separate pipeline rupture by suspected fuel thieves in San Juan del Rio in the neighboring state of Queretaro. There was no danger to the population, the firm added.
The president's crackdown on theft has significant public backing, though his decision to turn off pipelines to thwart the thieves disrupted 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.