The quarterly loss compared to a net profit of more than $25.4 billion in the same period of last year.
Pemex said the loss would have been even higher if not for a lower tax bill and a slower rate of deterioration of fixed assets, according to a filing with the Mexican stock exchange.
Revenue for one of the country's biggest companies during the April-to-June period totaled 409.5 billion pesos, down 1% from a year earlier
Falling sales were driven by a lower volume of crude exports, the filing showed, with sales from the shipments down 16% from the year-ago period.
Currency losses during the quarter totaled about 160 billion pesos compared to gains of more than 105 billion pesos in the second quarter of 2023, as the peso weakened about 10% against the U.S. dollar.
Crude and condensate liquids production stood at 1.784 million barrels per day (bpd), down about 6% from a year earlier, while Pemex refineries processed 886,000 bpd, a rise of more than 7%.
Pemex, one of the world's most indebted energy companies, reported a tick up in total financial debt to $99.4 billion as of the end of June, up about 2% from the end of last year.
At the direction of outgoing President Andres Manuel Lopez Obrador, Pemex has sought to boost domestic refining - which has been its biggest source of losses for years - while weaning itself off foreign gasoline and diesel imports.
The leftist leader, as well as like-minded successor President-elect Claudia Sheinbaum, who takes office in October, has argued that Mexico should be self-sufficient in motor fuels. Both have repeatedly couched the goal as a matter of "energy sovereignty."
But as Pemex directs more of its crude production to expanding its domestic refining volumes, a looming fall in oil output over the next few years will likely force the Mexican energy giant to swap its longstanding dependency on fuel imports for a new dependency on crude imports, Reuters reported earlier this week.