The Homer Ferrington gas drilling rig, operated by Noble Energy and drilling in an offshore block on concession from the Cypriot government, is seen during President Demetris Christofias' visit in the east Mediterranean, Nicosia November 21, 2011.
The Homer Ferrington gas drilling rig, operated by Noble Energy and drilling in an offshore block on concession from the Cypriot government, is seen during President Demetris Christofias' visit in the east Mediterranean, Nicosia November 21, 2011. Reuters / Handout .

Oil prices dipped on Thursday but still hovered near three-month highs after parts of Shanghai imposed new COVID-19 lockdown measures, as strong gains in refined products contributed to an ongoing bullish backdrop for crude oil.

Brent crude futures for August settled down 51 cents at $123.07 a barrel, a 0.4% decline, while U.S. West Texas Intermediate crude for July lost 60 cents, or 0.5%, to $121.51 a barrel.

Oil prices have been rallying steadily over the last two months, led by big increases in prices of refined products due to tight refining supply and surging demand.

Worldwide, refiners have shut facilities, and capacity is tight as well because of reduced activity in Russia, the world's largest exporter of crude and fuel, following its invasion of Ukraine.

Peak summer gasoline demand in the United States continues to boost crude prices. The U.S. and other nations have engaged in a series of releases of strategic reserves, but it has had limited effect as of yet with global crude production rising very slowly.

"I think higher energy prices are here for the balance of the year unless we see some breakthrough that allows a significant amount of crude oil to return to the market," said Andrew Lipow, president of Lipow Oil Associates in Houston.

U.S. gasoline stocks unexpectedly dropped last week, government data showed on Wednesday, indicating resilience in demand for the motor fuel during the peak driving period despite sky-high pump prices. U.S. four-week demand was around 9 million barrels per day, just 1% off of 2021's level.

"Even though prices are higher, we haven't seen any sizable drop in demand yet," said Thomas Saal, senior vice president at StoneX Financial. "That may happen any day now, but people are still driving."

Refiners have been unable to keep pace with demand. The United States is at near-peak processing capacity while China has kept refiners offline due to COVID-related curbs.

China's May exports jumped 16.9% from a year earlier as easing COVID curbs allowed some factories to restart, the fastest growth since January this year and more than double analysts' expectations.

That could suggest more refining capacity will eventually come online, but major Chinese metropolitan areas still have some COVID-related travel restrictions in place, dampening demand.

Parts of Shanghai began imposing new lockdown restrictions on Thursday, with residents of Minhang district ordered to stay home for two days to control transmission risks.