Two deadly earthquakes in September and several hurricanes and tropical storms

Mexican state oil company Pemex said Friday it posted a loss of $5.3 billion in the third quarter as output took a hit from two earthquakes and several storms.

The negative result ended a streak of three consecutive quarters in the black for the company, which is trying to get back on solid footing after years of declining production.

Two deadly earthquakes in September and several hurricanes and tropical storms again dented production last quarter, as Pemex was forced to shut down key refineries.

"The atypical coincidence of natural phenomena had a major impact on the level of crude processing," it said in a report to investors.

The company's crude output from July to September fell 12 percent from the same period last year, to 1.9 million barrels per day.

Pemex was notably forced to close Mexico's largest refinery, Salina Cruz in Oaxaca, after the southern state was rocked by an earthquake on September 7.

It said operations were due to resume there in the coming weeks.

Forced to import more gasoline and diesel to meet domestic demand, Pemex also took a hit from the weakness of the peso, which has tumbled against the dollar amid uncertainty over the future of the North American Free Trade Agreement between Mexico, the United States and Canada.

Pemex, Mexico's largest company, accounts for some 16 percent of the government's revenue.

But it has struggled in recent years.

President Enrique Pena Nieto enacted a landmark energy reform in 2014 that reopened Mexico's oil and gas sector to foreign investors after 76 years of state monopoly, seeking to breathe new life into it.

As a result, Pemex now faces stiff competition from private firms.

In 2016 it implemented a $5.5-billion cost-cutting plan and received a $4.2-billion cash injection from the government to get its books in order.