US oil closes up $1.76, or 3.81%, at $47.90 a barrel

Futures Now: Crude oil surges
Futures Now: Crude oil surges

Crude prices closed up about 4 percent on Tuesday as a rally in U.S. gasoline and diesel added support to oil markets already boosted by an industry strike in Brazil and force majeure for Libyan crude loadings.

The rebound, after a 1 percent drop in crude prices on Tuesday, came ahead of industry group American Petroleum Institute's (API) data on U.S. oil inventories, which were expected to a build in crude stockpiles.

"If you look at the supply situation, the bigger picture is bearish. But the price action suggests the path of least resistance is higher for now," said Scott Shelton, oil broker and commodities specialist at ICAP in Durham, North Carolina.

Read MoreHedge funds up short bets on oil again

Brent crude futures were up $1.73, or 3.55 percent, to $50.52 by 2:35 p.m. EDT (1835 GMT).

U.S. crude futures closed up 3.81 percent, or $1.76, at $47.90 a barrel.

Evercore: Buy big oil
Evercore: Buy big oil
Commodities make historic move
Commodities make historic move
Gas not dropping as fast as crude. Why?
Gas not dropping as fast as crude. Why?

"From a technical point of view, both oil contracts are displaying bullish characteristics, although neither has yet to make a decisive breakthrough," said Fawad Razaqzada, analyst at He pegged resistance for Brent at between $51 and $52 and for U.S. crude at above $48.50.

U.S. gasoline jumped nearly 6 percent and ultralow sulfur diesel was up almost 5 percent, extending gains in afternoon trade, on expectations the government will report that inventories of refined oil products fell last week despite forecasts that it will also announce a 2.8 million-barrel build in crude.

The government report is due on Wednesday, after the API numbers at 4:30 p.m. EDT (2130 GMT) on Tuesday.

Gasoline's "crack," or the profit refiners get for turning crude oil into that motor fuel, hit a one-month high.

Read MoreTop trader: Buy this oil stock for beta

An oil workers' strike in Brazil, the ninth biggest global producer, that began on Sunday cut around half a million barrels of output in the first 24 hours and has slowed state-run Petrobras' daily oil output by around 25 percent, according to the union.

In Libya, the export terminal at the eastern port of Zueitina was closed and force majeure has been declared on crude oil loadings, market sources said.

Oil prices have been trending higher since late October on suggestions of declining U.S. shale oil production.

But Goldman Sachs, Wall Street's leading voice on the oil market, said in a report that U.S. crude output could still rise this year and next, citing its study on oil wells.

Read MoreIs oil ready for a rebound?