By Stephanie Yang and Kevin Baxter

Oil prices closed higher Wednesday as signs of rising gasoline demand negated a larger-than-expected build in inventory levels.

Light, sweet crude for March delivery settled up 17 cents, or 0.3%, to $52.34 a barrel on the New York Mercantile Exchange, after trading as low as $51.50 a barrel earlier in the session. Brent, the global benchmark, settled up 7 cents, or 0.1%, at $55.12 a barrel.

Prices reversed course after the U.S. Energy Information Administration Wednesday reported an unexpected decline of 0.9 million barrels in gasoline inventories for the week ended Feb. 3, helping boost gasoline futures more than 4% and lifting oil prices as well.

"It's all about gasoline," said Bob Yawger, directorof the futures division of Mizuho Securities USA. "That's dragging [up] the rest of the market along with it."

Analysts and traders surveyed by The Wall Street Journal had expected gasoline stockpiles to rise by 1.1 million barrels on average, building on a surplus that has concerned many in the oil market this year.

"One of the more worrying aspects of recent reports was the weak implied demand numbers, though those concerns were alleviated somewhat this week, " said Anthony Starkey, manager of energy analysis at Platts Analytics, in a Wednesday email. "Demand rebounded across the board," improving the outlook for distillates and gasoline.

Mr. Yawger said oil prices also experienced some relief after EIA data showed a 13.8-million-barrel build in crude oil inventories last week.

While The Wall Street Journal survey forecast a rise of 2.5 million barrels on average, the official data fell short of the 14.2-million-barrelincrease reported by the American Petroleum Institute, an industry group. The API numbers sent prices lower Tuesday afternoon and early Wednesday.

Still, analysts had plenty of reasons to be concerned about the growing amount of oil in storage.

"I'd think that this is a lot of knee-jerk, yo-yo reaction," said Donald Morton, senior vice president at Herbert J. Sims Co., who runs an energy trading desk. "I don't think that this data is enough to move us out of the recent trends."

Market observers are growing more bearish than the previous months when prices were supported by production cuts from the Organization of the Petroleum Exporting Countries and several countries outside the cartel. Fears over growing U.S. stock levels and shale oil production are starting to overtake optimism from the OPEC deal, analysts said.

Norbert Ruecker, head of commodities research at the Zurich-based Julius Baer, said that the compliance level of between 80%-90% from OPEC is impressive. But he said the deal merely cancels out last year's supply excesses and needs to go deeper to make any significant impact.

According to the EIA's latest forecast, U.S. crude oil production will rise to 9 million barrels a day this year, with another 500,000-barrel-a-day increase in 2018. This view is reinforced by data showing the U.S. oil rig count is rising, said Platts RigData. This rig count includes U.S. onshore, U.S. inland waters and U.S. offshore Gulf of Mexico drilling.

The numbers are debated by Germany's Commerzbank, with analysts saying in a note that the U.S. is producing almost 9 million barrels a day already. It is likely that the figure will be higher and that next year's EIA U.S. production forecast of 9.53 million barrels a day could be higher still.

Gasoline futures settled up 4.4% at $1.5527 a gallon, their biggest one-day gain since Nov. 30. Diesel futures settled up 0.9% at $1.6360 a gallon.

Jenny W. Hsu contributed to this article.

Write to Stephanie Yang at stephanie.yang@wsj.com and Kevin Baxter at Kevin.Baxter@wsj.com

(END) Dow Jones Newswires

February 08, 2017 15:40 ET (20:40 GMT)

Copyright (c) 2017 Dow Jones & Company, Inc.