Benchmark crude for August delivery gained 48 cents to close at $106.48 per barrel on the New York Mercantile Exchange. Oil is up nearly $10 a barrel in July.
Pump prices keep rising. The average price for a gallon of gasoline rose to $3.66, the highest price since May 23. The average is up 16 cents from a week ago.
The price of oil drew support from another sizable decline in oil supplies. The nation's inventory of crude fell by 6.9 million barrels last week, bringing the three-week decline to 27.1 million barrels, the Energy Department said.
That was somewhat offset by a sharp decline in gasoline demand compared with last week. Gasoline consumption fell by 570,000 barrels from a week ago, when demand was boosted by drivers hitting the road for the July Fourth holiday. Gasoline supplies rose by 3.1 million barrels.
Analysts expected a decline of 2.5 million barrels in crude oil supplies and no change in gasoline supplies, according to a survey by Platts, the energy information arm of McGraw-Hill Cos.
The markets also weighed comments to Congress from Federal Reserve Chairman Ben Bernanke. He said the central bank had no firm timetable for cutting back on the bond purchases that have helped depress long-term interest rates.
The withdrawal of Fed bond purchases could push the dollar higher as U.S. interest rates would tend to rise. That would make oil a less attractive investment for investors with foreign currencies that have to be converted to dollars.
In London, Brent crude gained 47 cents to finish at $108.61 a barrel on the ICE Futures exchange.
In other energy futures trading on Nymex:
— Wholesale gasoline fell 2 cents to end at $3.11 per gallon.
— Heating oil rose 2 cents to finish at $3.07 a gallon.
— Natural gas dropped 5 cents to end at $3.63 per 1,000 cubic feet.
AP Writer Pablo Gorondi in Budapest contributed to this report.