U.S. crude oil hit $40 a barrel on Thursday for the first time since June 3 after gasoline futures led an afternoon rally on supply concerns and U.S. data showed a lower-than-expected rise in weekly crude oil stocks.

U.S. light crude (search) was trading 92 cents higher at $40.00 a barrel on the New York Mercantile Exchange (search), a psychologically important level which some analysts also worry is high enough to hurt global economic growth. In London, benchmark Brent crude rose 87 cents to $37.48.

Gasoline futures, which had eased earlier on news that inventories rose by one million barrels despite an anticipated drawdown ahead of a U.S. holiday weekend, rebounded to trade above its resistance level of $1.3000 a gallon.

Government data released on Thursday, a day later than usual because of a U.S. public holiday on Monday, revealed overall crude stocks had risen by 100,000 barrels to 305 million, compared with 283.2 million the same time a year ago.

The smaller-than-expected rise in crude stocks was explained by increased refinery output, analysts said.

Traders attributed gasoline's rise to speculation that the strong imports -- which have been bolstering U.S. stockpiles -- would taper off this month as rocketing European prices have made it uneconomic for refiners there to ship spot cargoes across the Atlantic.

"The arb is shut from Europe and gasoline demand has risen 800,000 barrels per day in the last two weeks. We're not going to see any relief on gasoline from Europe any time soon," said Nauman Barakat of brokers Refco.

Export cargoes of European-grade gasoline for delivery in late July into New York Harbor was garnering a premium of just a half cent to the August NYMEX contract, London traders said, adding that there was little incentive for exports.

News that British Petroleum Plc's refinery in Texas City, Texas, plans to shut down a distillate desulfurization unit for inspections next weekend also added to concerns over production constraints and supply tightness, traders said.

Oil prices have rallied by around $4 from the end of June as a series of supply disruptions, notably in Iraq and Nigeria, as well as product tightness, drove gains.

Most of the halted production is flowing again and the leading global exporter Saudi Arabia earlier this week pledged that a further OPEC (search) output rise of 500,000 barrels per day was definitely going ahead.

The Organization of the Petroleum Exporting Countries, which meets again on July 21 in Vienna, agreed last month to raise its output ceiling by two million bpd from July 1 and by an additional 500,000 bpd from August 1.

But analysts say the market is still on edge.

In particular, they are worried that Russian production could be disrupted by the troubles of oil major YUKOS, which pumps a fifth of Russia's crude oil.

YUKOS missed a midnight deadline to pay $3.4 billion in back taxes and faces the prospect of the government selling off its assets.