US oil settles down 1.5%, at $47.81 a barrel

Crude oil inventories up 3.1M barrels
Crude oil inventories up 3.1M barrels

Oil prices were volatile on Wednesday as government data showing a large U.S. crude inventory build surprised traders the morning after an industry group had reported a draw.

The U.S. government's Energy Information Administration (EIA) said crude inventories in the country rose by 3.1 million barrels last week, versus a 2.2 million-barrel build expected by analysts in a Reuters survey.

Just on Tuesday preliminary inventory data by the American Petroleum Institute had suggested a drawdown of 1.2 million barrels. Oil prices slid after the EIA report.

Read MoreInvestors tread carefully despite oil rally

The West Texas Intermediate (WTI) benchmark for U.S. crude closed down 72 cents, or 1.5 percent, at $47.81 a barrel, after rising more than $1 earlier. Brent, the global crude benchmark, was down 60 cents at $51.30 a barrel, wiping out earlier gains.

Oil prices rise but a lot can go wrong: Pro
Oil prices rise but a lot can go wrong: Pro

A rally between Friday and Tuesday had bumped up Brent and U.S. crude by about $4 each, as oil broke out of a month-long trading range on technical buying and supportive data.

The crude build reported by the EIA "will take some of the wind out of the market's sails," said Gene McGillian, senior analyst at Tradition Energy in Stamford, Connecticut.

Read MoreCould oil prices really shrink to… $20 per barrel?

"The report is bearish enough to break the back of the rally, he said. It's cold water on the market."

Tariq Zahir, trader in crude oil spreads at Tyche Capital Advisors in Laurel Hollow in New York, agreed.

"Overall, we have a real battle going on, with crude technically having broke out of the range we have been in for more than a month. $50 for WTI is in sight," Zahir said. "But fundamentally we are seeing builds and that should continue we feel in the weeks to come," he said.

Zahir cited the impending arrival of Iranian oil as nuclear-related sanctions against Tehran come off, and an Atlantic hurricane season that has so far done no damage to U.S. oil installations.

Read MoreRussia-Saudi oil cooperation is 'hogwash': Kilduff

On Tuesday, a monthly report by the EIA projected that global oil demand for 2016 will grow by the fastest rate in six years, suggesting a crude surplus was easing more quickly than expected.

Robin Bieber, director of London brokerage PVM Oil Associates, said the overall trend for oil prices would still be higher.

"The key technical indicators are positive," Bieber said. "It is not advised to be short."