LONDON - Oil prices dipped on Thursday but still hovered near three-month highs after parts of Shanghai imposed new COVID-19 lockdown measures although China's stronger-than-expected exports in May offered a boost to the demand outlook.

Brent crude futures for August had dipped 57 cents or 0.5% to $123.01 a barrel by 1327 GMT, while U.S. West Texas Intermediate crude for July was at $121.26 a barrel, down 85 cents or 0.7%.

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.

But while the Chinese trade figures were upbeat, oil prices eventually reversed their earlier modest gains.

"Of far greater importance is news that a district of Shanghai has been locked down today, reviving fears of another leg of China weakness due to its covid-zero policies. That is capping any gains in Asia today," said Jeffrey Halley, OANDA's senior market analyst for Asia Pacific.

"That said, it is indicative of how tight supplies are that oil has not retreated on that news today."

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.

"The export performance is impressive in the context of the country's multi-city lockdowns in the month," Stephen Innes, managing partner at SPI Asset Management, said in a note.

Meanwhile, peak summer gasoline demand in the United States continued to provide a floor to prices.

U.S. gasoline stocks unexpectedly dropped, data from the Energy Information Administration (EIA) showed on Wednesday, indicating resilience in demand for the motor fuel during the peak summer period despite sky-high pump prices.

"It's hard to see significant downside in the coming months, with the gasoline market likely to only tighten further as we move deeper into driving season," said ING's head of commodities research Warren Patterson.

(Additional reporting by Florence Tan and Jeslyn Lerh; Editing by Jane Merriman and Kirsten Donovan)