U.S. crude settled 3.6 percent up at $49.21 a barrel on Wednesday as a weaker dollar, fighting in Yemen and speculative buying boosted prices in spite of U.S. inventories building to record highs for an 11th week.
The dollar fell after disappointing U.S. durable goods orders for February. A weaker dollar makes commodities denominated in the greenback cheaper for holders of other currencies, typically boosting demand for such raw materials.
The dollar also fell against the euro after Europe's largest economy Germany reported that its business morale rise for the fifth month in a row in March, hitting the highest since July 2014. In France, business morale peaked at near 3-year highs.
Read More Oil headed to $100? $30? It may not matter
Fighting in Yemen raised concerns about the security of oil shipments from the Middle East. Analysts worry a proxy war might break out on the Arabian peninsula, home to the world's biggest oil fields, if the conflict draws in Saudi Arabia and rival Iran.
Oil prices retreated earlier in the day after the U.S. Energy Information Administration reported that inventories rose 8.2 million barrels last week, hitting 80-year highs for an 11th straight week. Analysts had expected a build of 5.1-million barrels.
But by afternoon, the market was up and running again as speculators jumped in to try and test new price highs.
was last up $1.20 at $56.31 a barrel.
Read MoreThe state that drills the most on Uncle Sam's turf
"Fundamentally, it should be a more bearish day in oil after the EIA numbers," said Tariq Zahir, fund manager and partner at Tyche Capital Advisors in Laurel Hollow in New York. "But there are more buyers than sellers, with people trying to get to the $50 level in WTI."
Gene McGillian, senior analyst at Tradition Energy in Stamford, Connecticut, was also of the view that prices had consistently defied market fundamentals of late.
"There seems to be a reluctance by the bears to be aggressive when fresh lows are put in the market," McGillian said.