NEW YORK (Reuters) - Oil prices rebounded from earlier losses to end higher on Wednesday, after the U.S. Energy Department said oil inventories rose for the first time in nearly three months, but was offset by strong demand for gasoline and distillate products and news that OPEC countries maintained heavy supply cuts in January.

Crude oil storage tanks are seen at the Kinder Morgan terminal in Sherwood Park, near Edmonton, Alberta, Canada November 14, 2016. Picture taken November 14, 2016. REUTERS/Chris Helgren

Crude oil futures ended higher for the fifth straight month, with U.S. futures gaining 7.7 percent in January, the best month for the contract since September.

The Organization of the Petroleum Exporting Countries and other producers including Russia continued their strong adherence to supply cuts, according to a Reuters survey.

OPEC members cut output by 1.8 million barrels a day until through the end of 2018, and a Reuters survey on Wednesday showed the members of the cartel achieved a 138 percent supply cut.

Overall OPEC output rose in January from an eight-month low, however, and one reason for the high compliance was a sharp fall in Venezuela due to an economic crisis there.

U.S. crude futures settled up 23 cents to $64.73 a barrel, a up 0.4 percent, after hitting a low of $63.92 shortly after the release. Brent crude rose 3 cents to $69.05 a barrel.

U.S. oil inventories rose 6.8 million barrels in the week to Jan. 26, after 10 straight weeks of declines, which had dropped supply to its lowest levels since early 2015.

The increase far exceeded expectations for a rise of 126,000 barrels. Analysts noted that refiners have been cutting activity while U.S. crude production has kept rising. [EIA/S]

Oil prices slipped immediately after the news, but rebounded on the back of the surprising 2 million-barrel drawdown in gasoline stocks, suggesting demand for products may be enough to limit seasonal inventory buildup.

“Lower gasoline inventories, combined with gasoline demand which is strong to start the year, bodes well for crude oil prices going forward,” said Rob Thummel, portfolio manager at Tortoise in Leawood, Kansas. “The dollar is weakening and that is also a positive for oil prices.”

March U.S. gasoline futures rose 1.3 percent to $1.8952 a gallon.

“If this week’s drop is due to weather-related, unplanned incidents it may not yet herald the onset of turnaround season. However, those days are rapidly approaching,” said David Thompson, executive vice-president at Powerhouse, an energy-specialized commodities broker in Washington. He said

The U.S. Energy Information Administration said production rose to 9.92 million bpd, close to the country’s record output of 10.04 mln bpd set in 1970.

Production is expected to hit 11 million bpd by 2019. This week ExxonMobil said it is wants to triple its production in Texas’ Permian Basin to 600,000 bpd within seven years.

Encouraged by higher crude prices, energy companies added 12 oil rigs last week, the biggest weekly increase since March.