Mexico’s state run oil company, Pemex, on July 27 reported a 32.8 billion peso (US$1.8 billion) second-quarter profit, helped by higher sales and lower financial costs.

It was the oil giant’s third straight quarter in the black, and it previously reported three continuous profitable quarters in 2006.

Revenue at the company jumped to nearly 322.5 billion pesos in the quarter, up 26% from 255.7 billion last year. During the quarter, the average price for Mexico’s crude export mix rose to $42.80 per barrel from $36.59 a year earlier.

“Our net accumulated positive result of 121 billion pesos during the first half of this year is a clear signal that we've improved; our finances are on the right path,” Juan Pablo Newman, the CFO, said on a call with analysts.

Crude exports were up 4.3% during the quarter to reach about 107,000 barrels per day (bbl/d).

Total crude production for the quarter, however, averaged 2.013 million barrels per day (MMbbl/d), down 7.5% compared to output during the same period last year. Pemex hit peak crude output in 2004 with 3.4 MMbbl/d.

Meanwhile, natural gas output fell about 12% during the quarter to average 4.336 billion cubic feet per day.

On the plus side, the company reported higher financial income and lower financial costs during the quarter.

Crude processing at the company’s six domestic refineries stood at 905,000 bbl/d in the quarter, a level described as “relatively stable” despite being far below the plants’ processing capacity.

Company officials reiterated that the Salina Cruz refinery, Pemex’s biggest, will resume operations on July 30 following an explosion and flooding that forced it offline last month.

Prior to revising its fourth-quarter earnings report last year, which originally showed a loss, the company had suffered a five-year stretch of losses amid a dozen years of declining crude production and a global slump in oil prices since late 2014.

Pemex’s total tax bill for the quarter stood at 100 billion pesos, up 47% compared to the 68 billion pesos in taxes the company paid in the previous April to June period.

Long a major source of tax revenue for the government, Pemex now contributes less than a fifth of federal revenue, down from more than a third a few years ago.