US crude inventories fell by 7.4 million barrels last week, the Energy Information Administration said. That exceeded the draw of 3 million barrels analysts predicted in a Reuters poll.
A weaker dollar, which makes oil cheaper for holders of foreign currencies, also supported prices.
"There's no escaping the benefits of a weaker dollar in the commodity space and oil is certainly basking in its decline," senior OANDA analyst Craig Erlam said.
Oil also drew support from signs that talks between the White House and Democrats in Congress on a new coronavirus relief package are making progress, although the sides remain far apart.
ALSO READ: Oil rebounds with equities offsetting the return of Opec+ supply
US factory data this week also showed an improvement in orders, which some analysts took as a hint of economic recovery.
Euro zone business activity returned to modest growth in July as some curbs imposed to stop the spread of the coronavirus eased, the Composite Purchasing Managers' Index from IHS Markit showed.
Rising prices come against the backdrop of a surge in coronavirus cases which could threaten a recovery in fuel demand.
Global coronavirus deaths surpassed 700,000 on Wednesday, according to a Reuters tally, with the United States, Brazil, India and Mexico leading the rise in fatalities.
"We see gasoline demand coming in close to 7% year-on-year lower through Q3, with gasoil/diesel registering a decline of some 4%, implying a continued slowdown of the recovery, with a global return to 2019 levels this year increasingly in doubt," JBC Energy said, referring to global consumption, which has collapsed due to lockdowns to help contain the pandemic.
The consultancy sees jet fuel demand down 50% year on year through the third quarter.
In the United States, the world's top oil consumer, distillate inventories rose last week to their highest in 38 years for the third week in a row, while Gulf Coast distillates were at record high levels, the EIA said. Gasoline stocks rose for a second straight week.
"As we approach the end of the driving season and enter into the fall heating oil season, refining margins are going to remain under pressure as gasoline and distillate inventories remain substantially above last year and we have been unable to cut into that overhang in a meaningful way," said Andrew Lipow, president of Lipow Oil Associates in Houston.