* Q2 net profit 32.8 bln yuan vs 34.1 bln consensus
* Sees volatile crude oil prices
* Shares end up 0.71 pct in Hong Kong before results (Adds details, background)
By Sui-Lee Wee
HONG KONG, Aug 26 (Reuters) - PetroChina Co Ltd, the world's second-most valuable oil and gas producer after Exxon Mobil Corp, posted a 4.2 percent rise in quarterly earnings, its best profit in 1-½ years but lower than analyst forecasts as higher oil prices and stronger production offset weak refining margins.
China's largest oil producer and its peers such as CNOOC Ltd have benefited from a 30 percent increase in crude oil prices in the second quarter.
But they also face an uncertain oil market and have been squeezed by weak refining margins, which have come under pressure from strict state controls on what they can charge for refined products such as gasoline.
"International crude oil prices may fluctuate drastically with high frequency over the near future, and the operating environment for the petroleum and petrochemical industries may face numerous uncertainties," the company said in a statement to the Hong Kong stock exchange.
Analysts say PetroChina may be unable to sustain strong profits in the second half if measures to cool the economy lead to a slowdown in demand for fuel, and if oil prices continue to trade around $70-$80 per barrel, similar to the average price of $72 in the same period a year earlier.
PetroChina generates about 80 percent of its earnings from exploration and production, compared with rival China Petroleum & Chemical Corp (Sinopec), which gets most of its revenue from refined products..
NATURAL GAS BOOST
PetroChina, which controls more than 60 percent of China's gas output, is expected to get a boost from a government decision in June to lift natural gas prices by 25 percent to spur supply of the cleaner-burning fuel.
Analysts say more increases are likely.
PetroChina earned 32.8 billion yuan ($4.82 billion) in the second quarter, up from 31.53 billion yuan a year earlier, according to a statement to the Hong Kong Stock Exchange.
That missed a 34.13 billion yuan average estimate in a Reuters poll of eight analysts.
PetroChina's first-half total crude oil output rose 1.7 percent on the year. The average realised crude oil price for the group in the first half was $72.42 a barrel, up 70.6 percent.
It processed 439.1 million barrels of crude oil in the first half, up 12.8 percent from a year ago.
PetroChina's Hong Kong shares have fallen about 9 percent this year, while Sinopec shares have lost about 12 percent and the benchmark Hang Seng Index is down about 6 percent. (Editing by Dhara Ranasinghe, Don Durfee and Chris Lewis)