A massive fire in the Gulf of Mexico caused by a gas leak was extinguished after a five-hour operation, state oil firm Pemex said in an official release.

According to an official press release from the firm, the fire began at around 5:15 am local time as a gas leak was detected in the 12-inch submarine pipeline that connects to a platform at Pemex's Ku Maloob Zaap oil development close to the Mexican State of Campeche.

Security protocols were activated and the incident was then dealt with help from nearby fire fighting vessels.

The pipeline was then closed while workers used liquid nitrogen to control the fire, as per reports. The contingency ended around 10:45 am local time, restoring normal operating conditions. No injuries or evacuees are reported, the oil company said in its release.

A root cause analysis of this incident will be conducted.

Ku Maloob Zaap is the company’s biggest crude oil production facility. It accounts for over 40 per cent of its nearly 1.7 million barrels of daily output, as per media reports.

Angel Carrizales, Executive Director of Mexico's oil safety regulator ASEA, in a tweet said that the event did not generate any spill.

The videos of the incident went viral on social media showing flames rising up to the ocean surface.