Oil prices hit 2016 highs on Thursday, with U.S. crude piercing the $40 psychological barrier, on optimism that major producers will strike an output freeze deal next month amid soaring gasoline demand in the United States.

A weaker dollar after a Federal Reserve policy decision on Wednesday that indicated two U.S. rate hikes this year instead of four also drew oil buyers using currencies such as the euro.

OPEC kingpin Saudi Arabia and non-OPEC producers led by Russia will meet on April 17 in the Qatar capital Doha, increasing the likelihood of the first global supply deal in 15 years.

"The remote possibility that a coordinated supply control effort comes from this meeting, assuming it even happens, has put market bears on the defensive," said Pete Donovan, broker with Liquidity Energy in New York.

Oil prices have surged more than 50 percent from 12-year lows since the Organization of the Petroleum Exporting Countries floated the idea of a production freeze, boosting Brent up from around $27 a barrel and U.S. crude from around $26.

On Thursday, the front-month in U.S. crude's West Texas Intermediate (WTI) futures CLc1 was up $1.52, or 4 percent, at $39.98 a barrel by 12:45 p.m. EDT, after setting a 2016 high at $40.08.

Brent crude's front-month LCOc1 rose $1.04 to $41.37, after earlier reaching the year's peak of $41.60.

"For now, the market is staying well supported, and the dollar is providing additional support," said Olivier Jakob, oil analyst at Petromatrix. "It will be difficult to return to the lows of the year."

WTI also briefly traded at a premium to Brent CL-LCO1=R on Thursday, the first time since January, as traders piled into the U.S. crude market on bets of an uptick in domestic oil exports.

U.S. crude has gained further traction on smaller stockpile builds of late, and surging gasoline consumption.

U.S. crude inventories last week climbed to its fifth straight week of record highs but by just 1.3 million barrels, a much smaller build than forecast, government data showed. Gasoline demand rose 6.4 percent over the past four weeks from a year ago.