Authorities believe construction workers accidentally pierced the pipeline while they laid foundations for a bridge nearby.
"Two valves (feeding the pipeline) have been closed and flames are dying out," the official said.
Two men were injured at the fire in the industrial town of Cuautitlan Izcalli.
State energy company Pemex said a private company operated the line.
A Mexican leftist rebel group last year set off bombs at gas and oil pipelines, disrupting supplies of crude oil and cutting off natural gas supplies to hundreds of manufacturers.
Author: Ksena Kochneva
273
A Mexican gas pipeline caught fire
A main highway into Mexico city was closed by the gas pipeline fire on Friday