Oil rose toward $52 a barrel on Thursday, partly in response to a more optimistic view of the world economy from the U.S. Federal Reserve that also helped drive equity markets to their highest level since early January.

U.S. light, sweet crude for June delivery was up 84 cents at $51.81 a barrel by 1130 GMT (7:30 a.m. EDT).

Brent crude was up 52 cents at $51.30.

Investors are looking to see if we're on the cusp of a real recovery, with consumer confidence starting to improve just as the U.S. driving season approaches, Bank of Ireland analyst Paul Harris said.

A surprise 4.7 million barrel decline in U.S. gasoline stocks ahead of the driving season and stock market gains had helped drive a 2 percent rise in oil prices on Wednesday.

Oil is on track to gain 3 percent this month, its third monthly increase. But its advance from February's $33 low has slowed down and prices seem confined in a $45-$55 range established over the past six weeks.

OIL INVENTORIES RISE

The World Health Organization (WHO) raised its threat level on the swine flu virus and said a possible pandemic was imminent. However, the WHO has stopped short of recommending travel restrictions or border closures.

Mexican President Filipe Calderon ordered a five-day partial shutdown of the economy to try to contain the virus.

Swine flu has become almost a sideshow for the oil market -- it might impact demand in specific areas like jet fuel, but if we can confirm the overall economy has bottomed, prices should slowly grind higher, Harris said.

Japan's oil demand has shown signs of stabilizing after months of deep contractions, helped by rising demand for gasoline.

But in the United States, crude oil stocks rose by 4.1 million barrels last week, the Energy Information Administration's weekly report showed.

This brings crude inventories to a new 19-year high. Distillate stocks rose by 1.8 million barrels.

Oil's price structure, where prices nearby are lower than those further forward, has encouraged traders to store crude.

Oil futures contracts for delivery further forward are trading at a significant premium to current prices, with oil for delivery one year hence above $61 a barrel.

Commerzbank analyst Eugen Weinberg said U.S. imports had been boosted by this market structure.

That additional volumes of crude are being sent to the U.S. at a time when demand for crude is stalling appears odd, Weinberg said in a research note.

(But) storage of this crude geographically near to where U.S. crude is priced enables the most efficient capturing of the value in the forward curve when trading in physical barrels of oil.

(Additional reporting by Jonathan Leff and Maryelle Demongeot in Singapore; editing by James Jukwey)