By David Hodari

Oil prices climbed Wednesday, after unexpectedly upbeat U.S. inventory numbers extended a rally that began Tuesday.

Brent crude, the global benchmark of prices, rose 4.2% to $42.36 a barrel and West Texas Intermediate futures, the U.S. benchmark, added 4.9% to $40.16 a barrel. Prices have pared some of this month's slide with their recent rebound, though they remain well below where they started the year with the coronavirus sapping demand.

Crude extended its gains after the Energy Information Administration released weekly inventory data showing the seventh drop in U.S. crude-oil stocks in eight weeks, with those inventories falling to a five-month low.

Reported remarks from department of health and human services personnel about the prospect of wide-scale coronavirus vaccines in early 2021 further boosted oil.

American Petroleum Institute inventory figures released late Tuesday, which showed an unexpected drop in U.S. oil stocks, were "certainly continuing the upward momentum we've had since yesterday," said Harry Tchilinguirian, global head of commodity markets strategy at BNP Paribas.

U.S. crude oil inventories fell by 9.5 million barrels in the week ended Sept. 11, a surprise when compared with market consensus expectations of a 1.4-million-barrel increase, according to Helge André Martinsen, senior oil market analyst at DNB Markets.

The API's data added to a handful of other factors that began to buoy crude prices Tuesday: Preparations for Hurricane Sally, which made landfall in Alabama early Wednesday, included the closure of more than a quarter of offshore oil production in the Gulf of Mexico, according to the Bureau of Safety and Environmental Enforcement.

Sally is the latest storm to disrupt the industry, after Hurricane Laura cut U.S. oil production by 400,000 barrels a day in August, according to an International Energy Agency report on Tuesday.

Prices dropped in recent weeks on fears of a stalling recovery in energy demand, rising coronavirus cases and increasing oil production, particularly from the Organization of the Petroleum Exporting Countries and its allies. OPEC's joint ministerial monitoring committee is due to meet Thursday to discuss the status of its continuing cuts.

Both OPEC and the IEA have their 2020 global oil-demand estimates this week, but the oil market appears split over whether inventories will build this year and next year.

Speaking at the Asia Pacific Petroleum Conference, the chief executive of commodities trading giant Vitol said Tuesday that oil inventories have been falling sharply since early summer and will continue their decline toward the end of the year, according to S&P Global Platts.

Those remarks were helping lift oil prices Tuesday and Wednesday, according to DNB Markets' Mr. Martinsen. He said it was particularly the case because the remarks contradicted comments from another big oil trader, Trafigura, earlier in the week.

Trafigura's co-head of oil trading, Ben Luckock, said he expected stocks to build toward year-end, Bloomberg reported.

With seasonal uptick in demand, the return of Chinese crude-buying and increasing refinery runs, Mr. Martinsen said he expects crude inventories to decline in November and December.

Dan Molinski contributed to this article.

Write to David Hodari at David.Hodari@dowjones.com