Jorge Alcocer said at least 75 others were injured after an explosion in Tlahuelilpan, a town more 120 kilometers (about 80 miles) north of Mexico City.
Most of the injured are in serious condition, Alcocer said.
State oil company Pemex said an investigation into the cause of the blast was underway. The company initially had said the explosion was caused by illegal taps in the pipeline, and Hildago Gov. Omar Fayad called on the community not to steal gasoline.
Residents in the immediate vicinity of the pipeline, which runs from the cities of Tuxpan to Tula, have been evacuated, Pemex said.
The fire resulting from the pipeline explosion has been extinguished, Mexican Secretary of Public Security Alfonso Durazo said on Twitter, and rescue teams have begun to recover bodies.
Mexican President Andrés Manuel López Obrador visited Tlahuelilpan and met with officials at a command center.
Pemex said the explosion would not affect gasoline distribution in Mexico City.
The explosion comes as gas stations in several Mexican states and the country’s capital have been running dry for nearly two weeks.
The López Obrador administration closed key pipelines in an effort to crack down on fuel theft, which the Mexican leader said cost the country an estimated $3 billion last year.
Drivers in Mexico have grown desperate.
Family members take turns waiting in long lines for gas. Some comb social media for clues about which stations are open. Others have simply decided to leave their cars at home.
Pemex said a new gas distribution system will have long-term benefits that outweigh any short-term cost.