In its weekly report, the Department of Energy said that U.S. commercial crude oil inventories fell by 4.2 million barrels in the week to May 20, but at 537.1 million barrels remained at historically high levels.
"We had a decent draw in headline crude numbers, that really carried us through a rally today," said Matt Smith of ClipperData.
Major oil futures climbed within striking distance of $50 a barrel. U.S. benchmark West Texas Intermediate for delivery in July advanced 94 cents to $49.56 a barrel on the New York Mercantile Exchange.
In London, Brent North Sea crude for July, the European benchmark, finished at $49.74 a barrel, up $1.13 from Tuesday's settlement.
"When you look at inventories, people start to realize the demand continues to be strong and production is starting to ebb, and that should get the market back in balance," said Phil Flynn of Price Futures Group.
The global oil market nosedived from above $100 a barrel two years ago to around $27 in early 2016, plagued by a stubborn glut.
They have since rebounded, aided by weeks of wildfires in Canada that have curbed oil production and unrest affecting energy infrastructure in Nigeria, Africa's biggest oil exporter.
Commerzbank analyst Carsten Fritsch said the recent price rebound was making the cost of North American shale oil attractive again, "which could dampen the fall in production in the coming months".
"What is more, oil production is gradually resuming in those regions of Canada plagued by wildfires," he said in a research note.
"We therefore do not expect to see prices remain above $50 per barrel for any length of time," he added.