U.S. crude inventories marked a fifth straight weekly increase, but oil prices rallied to their best gain in three months.

That doesn’t make sense at first glance. The degree to which oil rallied has some analysts stumped, but there are good reasons why oil prices are climbing.

Early Wednesday, the U.S. Energy Information Administration reported an increase of 3.4 million barrels in crude supplies for the week ended Oct. 23.

That was well above the increase of 1.6 million barrels forecast by analysts polled by Platts, but analysts surveyed by The Wall Street Journal looked for a bigger 3.7 million-barrel rise and the American Petroleum Institute Tuesday said inventories rose 4.1 million barrels.

“It looks like the majority of shorts got ahead of themselves and were looking for another high single-digit build that didn’t pan out, so they all ran for the door at once to unwind,” said Tyler Richey, co-editor of the 7:00’s Report.

The crude-supply climb wasn't as big as some expected and it was a lot lower than the increases traders have been accustomed to seeing over the last couple of weeks. The EIA had reported weekly jumps of eight million and 7.6 million barrels in its past two reports and Wednesday’s data marked a fifth weekly rise in a row.

“With traders seeing a series of huge builds over the last 4 weeks or so, and expecting another one, the market was rather oversold going into the report,” said Richey.

In the wake of the data, December crude CLZ25, -0.75% rose $2.74, or 6.3%, on Wednesday to settle at $45.94 a barrel on the New York Mercantile Exchange after tapping a high of $46.01. The settlement was the highest since Oct. 20 and the best gain for Nymex crude since Aug. 31, according to FactSet data.

Supportive factors

The rest of the weekly report did include some price-supportive data.

Refinery activity edged up, with refinery utilization pegged at 87.6% of capacity, compared with 86.4% a week earlier. That caused a rise in the amount of crude used for refining. Crude-oil imports were also down about 439,000 barrels a day for the week and petroleum-product stockpiles fell.

Gasoline supplies shed 1.1 million barrels, matching expectations of analysts polled by Platts. Distillate stockpiles, which include heating oil, declined by a more-than-expected 3 million barrels.

This indicates that demand for the crude products is strong, said Fawad Razaqzada, chief technical analyst at Forex.com.

Futures prices for gasoline US:RBX5 and heating oil US:HOX5 rallied on Nymex, and that offered another reason for oil prices to rally.

All of those supportive factors may have also made more traders recognize that oil companies are still struggling under the pressure of prices which are still more than 50% below their highs from last summer.

With earnings season in full gear, “we clearly see that the number of major firms are cutting on their [capital expenditures], so that means there will be less supply in the future,” said Naeem Aslam, chief market analyst at AvaTrade.

BP PLC BP, -1.35% on Tuesday outlined plans to cut spending and costs on the back of the sharp slump in oil prices.

Read: Oil prices will rebound much faster than market is predicting, Barclays says

Meanwhile, the U.S. Federal Reserve wasn’t expected to announce an increase in interest rates at its meeting Wednesday, which concluded shortly before oil prices settled on Nymex.

The market was “discounting the probability” that the Fed would begin raising rates at the meeting, said Tim Evans, chief market strategist at Long Leaf Trading Group. That “dynamic” was “commodity bullish.”

Shortly before oil prices settled Wednesday, the Fed did indeed leave interest rates unchanged but it also kept the door open for a possible hike at its next meeting in December. Oil pared some of its gains following the news.

Outlook

“ “If production begins to edge up again ... then we can expect the recent slide in prices to continue towards initial support at $40 a barrel.” ” — Tyler Richey, co-editor of the 7:00’s Report

Notwithstanding Wednesday’s rally, traders say it is still difficult to see beyond the five weeks of rising crude supplies.

And, despite expectations that reductions in oil-company spending will translate into lower output levels, total domestic oil production actually rose by 16,000 barrels a day to 9.1 million barrels a day, the EIA data showed.

“The fundamentals are neutral at best as U.S. output has fallen trendless in recent weeks,” said Richey.

“Looking ahead, U.S. production metrics will continue to be an underlying driver of the market, and if production begins to edge up again (specifically above the 4-week moving average currently at 8.626 million barrels a day for the lower 48 states), then we can expect the recent slide in prices to continue towards initial support at $40 a barrel,” Richey said.