(Adds details on sales, crude production and processing)
MEXICO CITY, July 27 (Reuters) - Mexican state-owned oil company Pemex on Friday reported a 163.16 billion peso ($8.2 billion) net loss for the second quarter due to foreign exchange losses and higher costs, according to a filing with the Mexican stock exchange.
That compares with a profit of 32.76 billion pesos in the year-ago period.
Sales rose 36 percent from a year earlier to 436.18 billion pesos on the back of higher crude prices and increased sales in Mexico.
Earnings before interest, taxes, depreciation and amortization, or EBITDA, increased 42 percent to 149.76 billion pesos.
Pemex's crude production slipped 7.3 percent in the quarter to an average of 1.866 million barrels per day, while natural gas production fell 9.7 percent to 3.915 billion cubic feet per day.
Meanwhile, crude processing at the company's six refineries dipped 22.2 percent to 704,000 bpd during the quarter despite a processing capacity of about 1.6 million bpd.
By comparison, Pemex's annual crude processing in 2017 averaged 776,000 bpd compared with 962,000 bpd in 2016. ($1 = 19.8730 pesos at the end of June) (Reporting by Adriana Barrera Writing by Anthony Esposito Editing by Michael O'Boyle and Jonathan Oatis)