Oil inched closer to $89 a barrel Wednesday ahead of weekly U.S. crude inventory figures that give a reading on the state of near-term demand for fuel.
By early afternoon in Europe, benchmark crude for September delivery was up 22 cents at $88.72 a barrel in electronic trading on the New York Mercantile Exchange. The contract rose 36 cents to end Tuesday at $88.50 per barrel in New York.
In London, Brent crude was up 18 cents at $103.60 on the ICE Futures exchange.
Oil was being helped by the positive mood on world markets, which led to rising stock exchange indexes around the world.
It "seems to be a 'risk on' day as general market sentiment has improved across the equity and commodity boards," said a report from Sucden Financial in London.
Despite that optimism, the price of oil has fallen from near $106 a barrel nearly three months ago as the world's major economies slow. Europe is mired in its deepening debt crisis, China's breakneck growth has waned and the U.S. recovery has stumbled.
Data Tuesday from China suggested that stimulus measures are starting to help manufacturers but the global economy is not out of the woods and remains vulnerable to further shocks from Europe.
The U.S. Department of Energy is set to release weekly fuel stockpile figures on Wednesday. Data from the American Petroleum Institute on Tuesday suggested that the DOE figures will show a rise in U.S. crude inventories, which would suggest demand remains weak.
Energy analysts at The Schork Report said an increase in inventories is likely to keep oil under $90 a barrel this week.
The conflict in Syria, as well as the unresolved disagreements between Western powers and Iran over Tehran's nuclear program supported oil.
"Ongoing tensions in the Near and Middle East should preclude any sharper fall in prices," said analysts at Commerzbank in Frankfurt.
In other Nymex energy futures trading, natural gas was down 3.9 cents at $3.148 per 1,000 cubic feet. Gasoline fell 2.58 cents to $2.70 a gallon and heating oil dropped 0.34 cent to $2.8229 a gallon.