Oil inched up on Tuesday, lifted by expectations of another crude stockpile drawdown in the United States but price gains were limited amid the reopening of Libya's largest oil field.

U.S. crude inventories were expected to have fallen for an eighth straight week and dropped 3.4 million barrels last week, a Reuters poll showed, ahead of weekly data.

Libya's Sharara oil field was gradually reopening after its latest shutdown, field workers said. Earlier in the day an oil official said it was shut again hours after reopening on Tuesday following a three-day pipeline blockade.

Sharara, which has been pumping up to 280,000 barrels per day (bpd) in recent weeks, has been affected by repeated shutdowns because of protests by armed groups and oil workers.

Brent crude rose 21 cents, or 0.4 per cent, to settle at US$51.87 a barrel.

Book-squaring ahead of the U.S. crude September contract's expiry on Tuesday added to price gains, traders and brokers said.

U.S. crude futures for September delivery settled 27 cents, or 0.6 per cent, higher at US$47.64 while the more active October contract ended the session up 30 cents at US$47.83.

U.S. gasoline futures also led the complex higher for most of the session and settled up 0.4 per cent at US$1.5908 a gallon as forecasts for heavy rain associated with the remnants of former tropical storm Harvey threatened to cause refinery flooding, traders said.

A tropical depression is expected to form over the southwestern Gulf of Mexico on Wednesday or Thursday.

"Traders of crude oil and gasoline will also have particular interest in the remnants of Tropical Storm Harvey expected to strengthen to Category 1 hurricane status as it crosses the Gulf of Mexico toward a possible Friday landfall on the Texas Coast," Tim Evans, Citi Futures' energy futures specialist, said in a note.

"While not a major storm, this will at least serve as a drill for refiners along the coast, in our view."

The Organization of the Petroleum Exporting Countries and non-OPEC producers including Russia have pledged to hold back about 1.8 million barrels per day (bpd) of output between January this year and March 2018 in order to tighten supplies and prop up prices.

Meanwhile, U.S. crude production has broken through 9.5 million bpd, its highest since July 2015. 

Some analysts say U.S. oil output growth will slow as energy firms cut the number of rigs drilling for oil. 

Still U.S. commercial crude inventories have fallen by almost 13 per cent from their March peaks, to 466.5 million barrels as refineries have continually processed record amounts of oil. <C-STK-T-EIA>

"Another decline in U.S. crude stocks may push prices somewhat higher again, but the upside may be limited - especially if U.S. crude production ticks higher again," said Hans van Cleef, energy economist at ABN AMRO.

Industry group the American Petroleum Institute will publish statistics on inventories for last week at 4:30 p.m. EDT, followed by official government data on Wednesday.